Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Duplicate quantity bug in IE6/IE7 + fix
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

Using IE6 and in early versions of IE7 (but not the latest), putting “1” quantity in the qty box on the product detail page then adding it to your cart will add 2 of the items. Leaving quantity blank and clicking “add to cart” only adds 1.

Similarly, if an option is unavailable (e.g., size XL is unavailable and an error message reflecting this is shown) 1 item will still be added to the cart.

/var/www/html/app/code/core/Mage/Checkout/Model/Cart.php

Changing:

protected function _setProductQuoteQty(Mage_Catalog_Model_Product $product$qty$replace false)
to
protected function _setProductQuoteQty(Mage_Catalog_Model_Product $product$qty$replace true)
fixes this issue. It also changes the default functionality a bit, since it flags it to replace an existing item instead of adding another one of the same, obviously. smile However, it does get it wroking until the core code is updated with a more complete fix.

This has been reported in the bug tracking: http://www.magentocommerce.com/bug-tracking/issue?issue=1237

Just thought I’d post it here too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rence
Jr. Member
 
Total Posts:  7
Joined:  2008-02-18
 

After leaving QTY blank, I “was” still seeing multiple items being added to the cart when using IE.

I unknowingly introduced this problem when I made the “add to cart” button a graphic. See the WRONG WAY and CORRECT WAY for codding this below.

WRONG SYNTAX (causes 2 items to be added in IE)

<input  type="image" src="add_to_cart.gif" onclick="productAddToCartForm.submit(); showhide('addingtocart');">

CORRECT SYNTAX

<a href="#" onclick="productAddToCartForm.submit();"><img src="add_to_cart.gif"></a>
 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

I have a similar problem, but my version is 1.1.8 and I use firefox.

When I put 1,2,3… items and add to Cart, then in the Cart, there are 2 or 3,4… items!!! It must be a Qty bug.

I can´t believe it´s happening in this version.

Please help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jeff Hope
Jr. Member
 
Total Posts:  3
Joined:  2008-09-02
 

I’m also having this problem, but ONLY with IE8 (beta).  Leave 1 in box, Add to Cart, you get 2 (along with 2 green confirmation messages at the top). Change qty in box to 2, Add to Cart, you get 4 (with 4 green confirmation messages).

This happens ONLY when adding to cart from the product detail pages, not the category pages where Add to Cart is also available - those work correctly.

I’m running the latest Magento, 1.2.1.

Funny thing is, this wasn’t happening before I upgraded. Not sure if it showed up this last upgrade, or the one before, but definitely wasn’t happening 2 upgrades ago. I haven’t changed the product detail template since then, so I have no idea what caused this.

Site is http://www.countrycuredhams.com/

Thanks,
Jeff

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

In firefox it seems right.

I know this problem exists and is very very very frustrating.

Good luck.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Netismine
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-10-28
 
Rence - 20 June 2008 06:08 PM

After leaving QTY blank, I “was” still seeing multiple items being added to the cart when using IE.

I unknowingly introduced this problem when I made the “add to cart” button a graphic. See the WRONG WAY and CORRECT WAY for codding this below.

WRONG SYNTAX (causes 2 items to be added in IE)

<input  type="image" src="add_to_cart.gif" onclick="productAddToCartForm.submit(); showhide('addingtocart');">

CORRECT SYNTAX
<a href="#" onclick="productAddToCartForm.submit();"><img src="add_to_cart.gif"></a>

also had this problem, switched from <input type="image"> to <a onclick=""><img /></a> and it worked

 
Magento Community Magento Community
Magento Community
Magento Community
 
inluxc
Jr. Member
 
Total Posts:  19
Joined:  2008-04-04
 

Thanks.. it worked for me too…

And thsi problem presists in the lastest IE7 and in IE8.

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

I’m using

<button class="button grnWhtButton" onclick="productAddToCartForm.submit()">

Which was fine in IE7. I had the duplicate quantity (and duplicate “Added to cart” message) in IE8 prior to forcing IE7 rendering.

- Mark

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nick Rigby
Member
 
Total Posts:  57
Joined:  2007-09-03
 

I am also seeing this bug, but only using Internet Explorer. I cannot reproduce in either Internet Explorer 6 or 7.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kcmr-z
Jr. Member
 
Total Posts:  3
Joined:  2009-06-01
 

The problem is the type="submit" attribute. I think this fires the form default action.
Removing type="submit" works!

<button onclick="productAddToCartForm.submit();"><?php echo $this->__('Add to Cart') ?></button>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chickenfanny
Jr. Member
 
Total Posts:  15
Joined:  2009-02-12
 

This is a really irritating bug.  I’m also seeing this, but only in IE 8.

Are you guys editing the addtocart.phtml file to fix the problem?  Here is the code from my addtocart.phtml:

<?php $_product $this->getProduct() ?>

<?php 
if($_product->isSaleable()): ?>
    
<fieldset class="add-to-cart-box">
        <
legend><?php echo $this->__('Add Items to Cart'?></legend>
        
<?php if(!$_product->isGrouped()): ?>
        
<span class="qty-box"><label for="qty"><?php echo $this->__('Qty'?>:</label>
        <
input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" /></span>
        
<?php endif; ?>
         
<div class="button_left_pro"></div>
        <
div class="left"><button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('add to cart'?></span></button></div>
        <
div class="button_right_pro"></div>
        <
div class="clear"></div>
    </
fieldset>
<?php endif; ?>

I don’t see a type=submit in there anywhere, and cannot figure out how to fix this problem.

Any help would be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lorenthal
Jr. Member
 
Total Posts:  1
Joined:  2010-05-04
 

Just in case anybody else is experiencing the same IE8 bug, you just need to add

type="button"

to the “Add to cart” button. It seems that IE8 assumes that a button without the type property is actually a submit button and fires the submit event twice (one automatically and another because of the onclick event).

So you will have:

<button type="button" class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michael Lambertz
Jr. Member
 
Total Posts:  12
Joined:  2009-12-21
 

Here an other working solution i found:

Open the template yourdesign/template/catalog/product/view/addToCart.phtml

and replace

<input ... onclick="productAddToCartForm.submit()" />

with

<input ... onclick="productAddToCartForm.submit(); return false;" />

Now it should work.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top