Reversing the order of the cart contents

By | April 9, 2008

In the osCommerce forum, someone posed an interesting question;

does anyone know how to reverse the order of the shopping cart dsiplay so that new products added will go onto the top of the list rather than the bottom.

Having thought about the question for a minute or two, this actually makes perfect sense and makes any shop more useable in my opinion. After all, if a customer has 20 items in their cart, it makes sense not to make them scroll to see the last item added.

So, how to do this?

The user in the osCommerce forum posted some code she had made – but it was problematic – and it’s no point posting broken code here. My solution is ALWAYS to go for the easiest way to do something…

Open up /includes/classes/shopping_cart.php and find;

[php]return $products_array;[/php]

Change it to;

[php]return array_reverse($products_array);[/php]

Save the file, upload and test your new look shopping cart 😉

REMEMBER: always try to do things the easiest way possible. If you make things easy, it’s just as easy to go back to standard osCommerce when (if) it all goes wrong!

Did this help you? Feel free to buy me a beer 😉

2 thoughts on “Reversing the order of the cart contents

  1. Debbie

    Works like a charm…and soooo simple!!! Can’t thank you enough.

Leave a Reply

Your email address will not be published.