Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Confirmation email: Change order of products


paulc1

Recommended Posts

Posted

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!

Posted

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.

Posted

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.

Posted

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...