Title: Order table
Last modified: August 31, 2016

---

# Order table

 *  Resolved [cschlichting](https://wordpress.org/support/users/cschlichting/)
 * (@cschlichting)
 * [10 years ago](https://wordpress.org/support/topic/order-table-1/)
 * I want to sort the product table by SKU code , it’s possible ?
 * [https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [10 years ago](https://wordpress.org/support/topic/order-table-1/#post-7338826)
 * 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](https://wordpress.org/support/topic/sort-by-sku-1?replies=4).
   
   If you haven’t worked with functions.php before, check out this guide: [How to use filters](http://docs.wpovernight.com/general/how-to-use-filters/)
 * Hope that helps!
    Ewout
 *  Thread Starter [cschlichting](https://wordpress.org/support/users/cschlichting/)
 * (@cschlichting)
 * [10 years ago](https://wordpress.org/support/topic/order-table-1/#post-7338827)
 * Thank you a lot!
    That was it I needed! 🙂
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [10 years ago](https://wordpress.org/support/topic/order-table-1/#post-7338830)
 * Awesome!
    Have a fantastic day!
 * Ewout
 *  [micasteph](https://wordpress.org/support/users/micasteph/)
 * (@micasteph)
 * [9 years ago](https://wordpress.org/support/topic/order-table-1/#post-9121022)
 * 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.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

## Tags

 * [order](https://wordpress.org/support/topic-tag/order/)
 * [sku](https://wordpress.org/support/topic-tag/sku/)

 * 4 replies
 * 3 participants
 * Last reply from: [micasteph](https://wordpress.org/support/users/micasteph/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/order-table-1/#post-9121022)
 * Status: resolved