Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    Unfortunately it’s not possible to change the styles of the quantity based on the content (actual quantity)

    However, you can add an extra class to the row based on the quantity, by using a filter (read this if you don’t know what to do with this):

    add_filter( 'wpo_wcpdf_item_row_class', 'wpo_wcpdf_product_quantity', 10, 4 );
    function wpo_wcpdf_product_quantity ( $classes, $template_type, $order, $item_id = '' ) {
    	$item_meta = $order->get_item_meta( $item_id );
    
    	if ( !empty($item_meta['_qty']) ) {
    		$qty = (int) array_shift( $item_meta['_qty'] );
    		if ($qty > 1) {
    			$classes = $classes . ' multiple';
    		}
    	}
    
    	return $classes;
    }

    You can then enter the following in the “Custom styles” box on the customizer tab, which will make the higher quantity bold:

    .order-details tr.multiple .quantity {
    	font-weight: bold;
    }

    If you need more help with this or any other questions, please email us at [email protected] (include order number or license key). As a paying customer you’re entitled to priority support! We’re also not allowed to use this forum for support of our premium extensions.

    Ewout

    Thread Starter littleneogeo

    (@littleneogeo)

    Hi,

    thank you for your answer.
    I found yesterday another method :
    adding this code in packing-slip.php template :
    $a = 0;
    foreach ($item_columns as $column_key => $column_data) {
    if ($a < 3) {
    printf(‘<td class=”%s”><span>%s</span></td>’, $column_data[‘class’], $column_data[‘data’]);
    } else {
    if ($column_data[‘data’] > 1) {
    printf(‘<td class=”%s” style=”color:blue;font-size:30px;font-weight:bolder;”><span>%s</span></td>’, $column_data[‘class’], $column_data[‘data’]);
    } else {
    printf(‘<td class=”%s”><span>%s</span></td>’, $column_data[‘class’], $column_data[‘data’]); }
    }
    $a++;
    }

    it works well like this.. ??

    Plugin Contributor Ewout

    (@pomegranate)

    Thanks for sharing! However, I would still recommend the method with the filter as described in my previous post, as this is non-destructive – you will still get all the template updates with that method.

    Have a great day!
    Ewout

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change class of quantity’ is closed to new replies.