Internet Explorer Adds Twice the Quantity to Cart

Written by Sid Vel

Topics: Magento

We all like to style our Magento add to cart button as an image button. The problem is that IE 8 (Internet Explorer 8) will add the product twice and cause the quantity of that product in the cart to double up. There is an easy fix to this problem.

Solution

<input type="image" src="<?php echo $this->getSkinUrl('add-to-basket.png') ?>"
name="image-button" onclick="productAddToCartForm.submit(); return false;" />

Notice the return false; that I’ve added after the productAddToCartForm.submit().

This will fix the problem of IE submitting the add to cart button twice.

Update (Thanks Barcaro) :
File where edit is to be made…
app/design/frontend/default/default/template/catalog/product/view/addtocart.phtml
(change /default/default/ to your custom template path).

12 Comments Comments For This Post I'd Love to Hear Yours!

  1. Matt says:

    thanks – you saved my day.

  2. Barcaro says:

    The file to patch is this one:

    app/design/frontend/default/default/template/catalog/product/view/addtocart.phtml

    (change /default/default/ to your custom template path).

    Thank you!

  3. jazkat says:

    Hey Sid,
    thanks so much for this!!!

  4. Iwin says:

    Thanks. Just what I needed.

  5. ricardo says:

    “email (will not be published)” Internet Explorer

  6. Peter says:

    You have to modify the list.phtml accordingly, for the case if someone adds to the chart direct from the listing.

    app\design\frontend\…\…\template\catalog\product\list.phtml

    <button type="button" title="__(‘Add to Cart’) ?>” class=”button btn-cart” onclick=”setLocation(‘getAddToCartUrl($_product) ?>’); return false;”>__(‘Add to Cart’) ?>

    Notice the “return false” which has been added. Around line 57.

  7. Thank you very much, its Great !

  8. amresh says:

    Thanks a lot, Sid.

  9. Mohit says:

    Thanks for your great help……

    You saved my precious time………..

  10. Robert Went says:

    Perfect, you just saved me hours!

12 Comments Trackbacks For This Post

  1. IE8 Adds Twice to Basket in Magento « Telescope Studios
  2. Day Four of Building a Magento Store / Sci-Fi Stuff Blog

Leave a Comment Here's Your Chance to Be Heard!