VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: inkomico on August 18, 2014, 21:39:00 PM

Title: Ordering invoice items by SKU [Solved]
Post by: inkomico on August 18, 2014, 21:39:00 PM
Is there any way to ordering items by SKU on the invoice?

I created the invoice_items.php override but I don“t know how to ordering.

Thanks.
Title: Re: Ordering invoice items by SKU
Post by: GJC Web Design on August 19, 2014, 01:11:23 AM
the items are in any multi dimensional array - research 'array ordering php'

e.g.

usort($myArray, function($a, $b) {
    return $a['product_sku'] - $b['product_sku'];
});
Title: Re: Ordering invoice items by SKU
Post by: inkomico on August 19, 2014, 15:40:44 PM
Quote from: GJC Web Design on August 19, 2014, 01:11:23 AM
the items are in any multi dimensional array - research 'array ordering php'

e.g.

usort($myArray, function($a, $b) {
    return $a['product_sku'] - $b['product_sku'];
});

Thanks!

The solution:


$list = $this->orderDetails['items'];

function order_by_sku($a, $b)
{
return ($a->order_item_sku > $b->order_item_sku);
}
usort($list, 'order_by_sku');