Magento – Magento add-to-cart buttons on homepage don’t update cart

addtocartmagento-1.8shopping-carttotals

Problem relates to Internet Explorer 11 and Google Chrome (but sometimes it works in Google chrome and sometimes not).

The add-to-cart buttons on the product list on the homepage of Magento 1.8 does not update the "total cart sum" and there's no green box pop-up with the "product-x added to cart!" confirmation text.

But after clicking on a category the green box suddenly turn up with confirmations on all products added on the homepage, and the "total cart sum" is correct.

Add-to-cart buttons in category products lists works fine as well as add-to-cart buttons on product pages.

Current html for the add-to-cart buttons on the product list on the homepage:

<div class="actions clearer">
<button type="button" title="Buy" class="button btn-cart" onclick="setLocation('http://mydomain.nu/index.php/checkout/cart/add/uenc/aHR0cDovL3N1bmRhcmUubnUvaW5kZXgucGhwLw,,/product/13/form_key/8Epibh9PEQSDwzRy/')">
<span><span>Buy</span></span></button>
</div>

Current html for the add-to-cart buttons in the product list on categories:

<div class="actions clearer">
<button type="button" title="Buy" class="button btn-cart" onclick="setLocation('http://mydomain.nu/index.php/checkout/cart/add/uenc/aHR0cDovL3N1bmRhcmUubnUvaW5kZXgucGhwL21pbmVyYWxzLmh0bWw,/product/134/form_key/8Epibh9PEQSDwzRy/')">
<span><span>Buy</span></span></button>
</div>

Best Answer

It looks like you have hard-coded the form key into that link. It must be unique for each and every visitor. Additionally, make sure that you have caching disabled for the block that is inserting that link. How you do that depends on how the block is being inserted.

This is the method you can use to get the URL with a unique form key:

Mage::helper('checkout/cart')->getAddUrl($_product);
Related Topic