paulc1 Posted October 15, 2009 Posted October 15, 2009 Hi, I've been hunting on the forum and in the code but I haven't found a way to do this: I need to order the products in the confirmation email by products_id rather than the order in which they were added to the card which is the way it seems to be by default. My colleagues fulfilling the orders have a very precise setup in the warehouse and I'm trying to list them in exactly the order they have them stored. Thanks!
♥ecartz Posted October 15, 2009 Posted October 15, 2009 In checkout_process.php, find for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { and add before it function cmp_order_product_id($a, $B) { return ($a['id'] - $b['id']); } usort($order->products, 'cmp_order_product_id'); and see if that does what you want. Always back up before making changes.
paulc1 Posted October 16, 2009 Author Posted October 16, 2009 Hi, thanks for that. That seems to just reverse the first 2 items. Do you have any idea how to sort them by id? As far as I can understand, they are stored in the session rather than selected from the DB each time. In checkout_process.php, find for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { and add before it function cmp_order_product_id($a, $B) { return ($a['id'] - $b['id']); } usort($order->products, 'cmp_order_product_id'); and see if that does what you want.
♥ecartz Posted October 16, 2009 Posted October 16, 2009 There is a bug in that code. $B should be $b. It looks like the forum is mangling it. function cmp_order_product_id($a, $b ) { return ($a['id'] - $b['id']); } usort($order->products, 'cmp_order_product_id'); Adding a space between the b and the ) seems to work. Always back up before making changes.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.