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

    (@pomegranate)

    Hi!
    Yes this is possible, but you need to add a small bit of code to your theme functions:

    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 (!isset($a['sku'])) $a['sku'] = '';
        if (!isset($b['sku'])) $b['sku'] = '';
        if ($a['sku']==$b['sku']) return 0;
        return ($a['sku']<$b['sku'])?-1:1;
    }

    This is an improved version of this function.
    If you haven’t worked with functions.php before, check out this guide: How to use filters

    Hope that helps!
    Ewout

    Thread Starter cschlichting

    (@cschlichting)

    Thank you a lot!
    That was it I needed! 🙂

    Plugin Contributor Ewout

    (@pomegranate)

    Awesome!
    Have a fantastic day!

    Ewout

    I tried to add this though the “Code Snippets” plug in as I’m new and not familiar with editing code. It didn’t make any change to my invoice. All of the items still showed up as they were ordered. I checked and made sure the SKU is showing up on the invoice. Is there anything right off that I might be doing wrong? I only use this as a packing slip, I don’t need to send this to customers. Thank you for any advice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Order table’ is closed to new replies.