HummingbirdUK main logo

Coding solutions to business problems

About us

We use code to create solutions to business challenges, bottle-necks and headaches.

If you think your business has a problem that can be solved through code, we are happy to chat things through without any obligation.

Get in touch

Updating cart quantities in Magento 1.8

Home / Blog / Updating cart quantities in Magento 1.8

Written by Giles Bennett

Another issue which has cropped up on a number of clients' sites after an upgrade to Magento 1.8 is that they can't update cart quantities any more. The functionality still appears to be there - you change product quantities and hit the 'update basket' button - but it doesn't actually do anything.

If this is happening to you, the chances are that you're using a custom template file for template/checkout/cart.phtml in your theme - with the recent upgrade a small change has been introduced to the base version of this file which, since you're using a custom version, won't be reflected in your page.

One approach is simply to delete the cart.phtml file, which forces Magento to fall back on the base file - but if you've got a custom version of that file the chances are you've made some changes to it, which would be wiped out if you went down this route.

The better approach is to add the updated lines to your own cart.phtml file - to fix the specific issue at hand there are two additions which need to be made :

Towards the top of the file, find the line :

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

and after it add in this line :

<?php echo $this->getChildHtml('form_before') ?>

Shortly after that, look for the line :

<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">

and check that after it there is the following line :

<?php echo $this->getBlockHtml('formkey'); ?>

If not, add it in.

Then, further down the file, look for the code which outputs your 'clear shopping cart' button - if you've not customised your installation, this should look something like this :

<button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>

Immediately after it, paste the following lines :

<!--[if lt IE 8]>
<input type="hidden" id="update_cart_action_container" />
<script type="text/javascript">
    Event.observe(window, 'load', function()
        // Internet Explorer (lt 8) does not support value attribute in button elements
        $emptyCartButton = $('empty_cart_button');
        $cartActionContainer = $('update_cart_action_container');
        if ($emptyCartButton && $cartActionContainer) {
            Event.observe($emptyCartButton, 'click', function()
                $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
                $cartActionContainer.setAttribute('name', 'update_cart_action');


Save the file, upload it to your theme's template/checkout/ folder (remember to keep a backup of your original cart.phtml) and you should be good to go!

Author : Giles Bennett

About the author

Giles Bennett built his first website in 1996, and is old enough to miss Netscape Navigator. Initially a lawyer, he jumped ship to IT in 2008, and after 5 years as a freelancer, he founded HummingbirdUK in 2013. He can be reached by email at