Reversing item order in the Zen Cart Shopping Cart

By default, items in your shopping cart in Zen Cart are shown in the order they are added to the cart. The first one is at the top, the second is below that, and so forth.

Generally this is desirable, but if your business involves taking telephone orders, especially of long lists of products, it’s easy to reverse it to show the last item added first instead. This can be useful for confirming as you add item by item.

Modify the file

includes/templates/YOUR_TEMPLATE/templates/tpl_shopping_cart_default.php

Look for

foreach ($productArray as $product) {

and change this to

$productArray = array_reverse($productArray);
foreach ($productArray as $product) {

And you’re done! Items will now appear in the opposite order – last added, first shown.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.