Sort and Separate
-
The customer wants products on the invoice separated by category with a line between the categories and the products in alphabetical order. Is this possible. If so, how? I have the products in alphabetical order with this code:
add_filter( ‘wpo_wcpdf_order_items_data’, ‘wpo_wcpdf_sort_items_by_name’, 10, 2 );
function wpo_wcpdf_sort_items_by_name ( $items, $order ) {
usort($items, ‘wpo_wcpdf_sort_by_name’);
return $items;
}function wpo_wcpdf_sort_by_name($a, $b) {
if ($a[‘name’]==$b[‘name’]) return 0;
return ($a[‘name’]<$b[‘name’])?-1:1;
}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sort and Separate’ is closed to new replies.