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

Page 1 of 2
In IE the Add to Cart button adds the item twice
 
DanGates
Jr. Member
 
Total Posts:  4
Joined:  2009-01-12
 

Hi there,

I’m having a strange problem at the moment whereby when someone adds an item to the shopping cart Magento adds twice the quantity wanted to the cart - this only happens in IE, but it works fine in Firefox.

I’d appreciate any ideas/fixes at all! I must admit I’m well and truly stumped by this.

Thanks for anything you can suggest.

Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
DanGates
Jr. Member
 
Total Posts:  4
Joined:  2009-01-12
 

Bumped!

No one have any idea? I don’t even know where to start looking :/

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
d4ufnky1
Jr. Member
 
Total Posts:  27
Joined:  2008-08-22
 

Hi,

I’m having this issue also, whenever I add a product to the cart it appears to be adding it twice.

I can change it to 1 and update cart but what customer is going to want to do that?

Any ideas?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
DanGates
Jr. Member
 
Total Posts:  4
Joined:  2009-01-12
 

Hi D4ufnky1,

This was eventually solved - the thing that gave us this problem was a Javascript error with the add to cart button. I’m not sure of the exact details because it wasn’t me that solved it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dunc
Member
 
Avatar
Total Posts:  56
Joined:  2008-08-05
 

I had this problem too, I found that the “add to cart” button in the list and grid view worked fine but in product view it added twice so I replaced

onclick="productAddToCartForm.submit()"
with
onclick="setLocation('"<?php echo $this->getAddToCartUrl($_product?>')"
in the file “.../template/catalog/product/view/addtocart.html” which solved the problem. I hope that helps anyone else with the problem
 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

I have exactly the same problem.

I tried your fix Dunc, though i fixed your syntax

onclick="setLocation('"<?php echo $this->getAddToCartUrl($_product?>)"
to
onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"

to avoid ‘unterminated string constant’

anyway… it had no effect. Items added to cart from product view add the quantity twice,

why is this JS at all?

EDIT: Happens on IE and FF

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

Well im completely stumped.

Can anyone explain why

<button class="form-button" 
onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart'?></span></button>

Works

but

<input type="image" alt='<?php echo $this->__('Add to Cart') ?>' 
src="<?php echo $this->getSkinUrl('images/add_to_cart_btn.png') ?>" 
onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')" />

does not ?!?!

I looked at the produced code and both the <button> and the <input> both have the exact same onclick

setLocation('http://myserver.com/checkout/cart/add/uenc/aHR0cDovLzExOS42My4yMDQuMTMxL3NvYS1yYWlsLW1vdW50aW5nLWtpdC0zeDE3NXcuaHRtbA,,/product/1027/')

however the next page will add the product quantity twice when the input is clicked?
the notification “ <product> successfully added to your shopping cart” is displayed twice.

Edit:-

I have the buttons above side by side (<input> and <button> tags) on firefox both add the quantity twice, on IE only the <button> adds twice.

Edit Two

I have gone back to

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

and things seem to be working. I would love to know why the exact same onclick when using an <input> does not work

<input type="image" alt='<?php echo $this->__('Add to Cart') ?>' src="<?php echo $this->getSkinUrl('images/add_to_cart_btn.png') ?>" 
onclick="productAddToCartForm.submit()" />
 
Magento Community Magento Community
Magento Community
Magento Community
 
Yeen
Jr. Member
 
Total Posts:  3
Joined:  2008-09-11
 

it seems just happens in IE8, and after i add a Configurable Product. i use ver. 1.2.1.2, how about ver. 1.3.1?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Felle
Jr. Member
 
Total Posts:  23
Joined:  2009-04-15
Leipzig
 

same in 1.3.0

 
Magento Community Magento Community
Magento Community
Magento Community
 
Felle
Jr. Member
 
Total Posts:  23
Joined:  2009-04-15
Leipzig
 

And still the same in 1.3.1

Edit: found that: http://www.magentocommerce.com/bug-tracking/issue?issue=6147

but Version 1.3.1.1 didn’t solve my problem.
Now I changed the

<button type="button" class="form-button" onclick="productAddToCartForm.submit()">

to

<button type="button" class="form-button" onclick="productAddToCartForm.submit(); return false;">

in ../template/catalog/prduct/view/addtocart.phtml (ca. line 37 in default template) and all is fine!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jfcromp
Member
 
Total Posts:  58
Joined:  2009-05-08
 

Felle you’re a life saver!

Adding return false after the javascript function call actually worked!

 
Magento Community Magento Community
Magento Community
Magento Community
 
GrG
Member
 
Total Posts:  41
Joined:  2008-11-12
 

Hi guys,

Just for information, If you have a button included in the form, IE8 will treat your click by calling :
1. You’re onclick action (and you submit your form)
2. The event is “bubbled” to the form, and click on the button means : “submit the form”, so the form is submitted another time !

to avoid this : Put your button away from the form (close the form tag and put the button after) or, send a return false in your onclick event so that the event is not treated anymore and so not submitted a second time ! (another option is to remove your onclick and precise the action in the form action)

My 2 cents,

GrG

 
Magento Community Magento Community
Magento Community
Magento Community
 
susanjoy
Jr. Member
 
Total Posts:  8
Joined:  2009-03-17
 

Just upgraded to IE8 and had this same problem. I implemented Felle’s fix and it fixed it, just wanted to say thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
C2K
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2007-09-04
Eindhoven
 
Felle - 18 May 2009 02:07 AM

And still the same in 1.3.1

Edit: found that: http://www.magentocommerce.com/bug-tracking/issue?issue=6147

but Version 1.3.1.1 didn’t solve my problem.
Now I changed the

<button type="button" class="form-button" onclick="productAddToCartForm.submit()">

to

<button type="button" class="form-button" onclick="productAddToCartForm.submit(); return false;">

in ../template/catalog/prduct/view/addtocart.phtml (ca. line 37 in default template) and all is fine!!!

Thanx worked fine!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kneemahp
Sr. Member
 
Total Posts:  116
Joined:  2008-08-07
 

i just wanted to say i was having this problem and felle’s solution worked perfectly!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mike
Member
 
Total Posts:  43
Joined:  2007-09-11
Los Angeles, CA
 

I, too, would like to offer my HEARTY THANKS to Felle for the clear, concise & extremely helpful solution. THANK YOU!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2