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

    (@pomegranate)

    Hello Metbar,
    You can do this by adding the following code to your themes functions.php:

    add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_sort_items_by_sku', 10, 2 );
    function wpo_wcpdf_sort_items_by_sku ( $items, $order ) {
    	usort($items, 'wpo_wcpdf_sort_by_sku');
    	return $items;
    }
    
    function wpo_wcpdf_sort_by_sku($a, $b) {
    	if ($a['sku']==$b['sku']) return 0;
    	return ($a['sku']<$b['sku'])?-1:1;
    }

    Hope that helps!
    Ewout

    Thread Starter metbar

    (@metbar)

    Hi Ewout.

    Thank you for your reply. I get this when I enter the code in functions.php:

    Fatal error: Call to undefined method DOMText::getAttribute() in /home/danoptik/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/lib/dompdf/include/cellmap.cls.php on line 437

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Metbar,
    Can you enable output to HTML (via the Status tab) to see if any errors are displayed?

    Ewout

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort by SKU’ is closed to new replies.