About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

StumbleUpon It! DIGG It!

Reversing the order of the cart contents

Written By Gary on Apr 09 2008 · Comments (2)

Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


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:
  1. return $products_array;

Change it to;

PHP:
  1. return array_reverse($products_array);

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 Comments

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

    Comment by Debbie — April 9, 2008 @ 4:36 pm


  2. Debbie – you're welcome.

    Comment by Gary — April 9, 2008 @ 4:38 pm


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!