New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/cart?add-to-cart=ID adds the item to cart twice #5400
Comments
I don't think that can be worked around HOWEVER, our internal functions for generating add-to-cart urls always use the permalink. Permalinks have a trailing slash. This means the only time you'd get /cart? is if you had some code removing trailing slashes, or you had some external code creating that add to cart url. If you have a case where WC core itself is not adding a trailing slash, add more info and reopen. |
why the heck is this closed...this is still a persisting problem.... |
@noob1211 , I opened this ticket as I had an issue on one of the sites I worked on. The problem was that the url was generated by the users theme. If you look into WC core you wont find URLs like these being generated so this is not something that should be fixed within WooCommerce but rather the code that generates the erroneous url. |
I understand what happening with "/cart?add-to-cart" and "/cart/?add-to-cart" (slash, redirects...) but in my WooCommerce this happening with and without slash :) With slash product added twice and without slash product added 4 times (2 x 2)! But this happening only when I use /store/checkout/?add-to-cart. With /store/cart/?add-to-cart all fine. Any ideas or suggestions? Seems like WooCommerce doing something before open checkout page (maybe look at cart page or something). Updated: I also have absolutely identical site on local server and I have this bug only on production server. What is going wrong... Updated 2: Find another ticket about this issue. #1611 |
This is how I fixed it for www.semipreciousWholesale.com - I changed the static page selection to none. |
I fix this adding / (slash) before ? e.g. https://site.com/url/?add-to-cart=id not https://site.com/url?add-to-cart=id |
I'm adding a variation product via ajax to "/cart/?" and still getting the item added twice as well. Any solutions out there for variations ids? |
I've seen this problem related to WooCommerce Pricing Tables as well. If you add an item to the cart, then click the View Cart link in the confirmation message, it adds a second item. |
oh GOD, this issue keeps coming back...even in latest Wordpress update not resolved. This is becoming like Magento! |
It's not something WordPress will resolve; this is a problem on your site which probably didn't get resolved before. Check .htaccess to ensure it's not removing or redirecting to pages without end-slashes. WooCommerce cannot prevent your server redirecting. |
Many of us are not using Apache, but running nginx these days, so .htaccess would have no effect. Any suggestions for resolving this issue on nginx? |
Look at the server config/nginx equivalent? Thats even if it's the same issue; you can look at the browser dev tools to see if any of the resources on the page have add-to-cart query string appended, or see if there is indeed a redirect from slash/non-slashed versions of the page. |
An additional redirect was indeed causing the issue for me. Thanks @mikejolley. |
@RumenGeorgieff thank you. it does work. |
Just adding my comment if it helps anyone. The redirect can also happen if you have http redirecting to https. So make sure in that case, you start with https in the url itself so it does not need redirection. |
"Permalinks have a trailing slash" is an assumption that is not reliable, because WordPress allows me to use a permalink structure that omits it. I had this issue on a site I'm working on -- so I had to add a trailing slash to my permalink structure just to make WC happy so that WP would stop redirecting from |
For those of you still having issues, I have found a fix to this. This verifies that the cart's quantity will only be one for that item, and also redirects you to the cart. It worked for me and hopefully this helps any of you out that still have this problem. |
I tried adding the quantity and that didn't seem to have an effect, but @garrettw idea with the URL worked great. I changed this Just removing the slash after cart did the job. |
Hi, So try adding shop or store whatever url you are for your website. Thanks :) |
The solution for me was a little bit different, but it was also a redirect caused by a double slash '//' PS: if your using Chrome goto DevTools->Network, turn on preserve log. Then you can see if your being redirected. |
I was able to fix this by TURNING OFF "Redirect to the cart page after successful addition" under WooCommerce > Settings > Products Hope this helps someone else. Toodles. |
5 years later, still broken. |
@mikejolley could you address my comment from a year ago as well as some other since that time? and maybe reopen this? |
I am having the exact same issue. I tried all the alternatives mentioned here without success. |
Had the same issue and read the entire post looking for an answer.
Then I used it in my customized product page and it worked fine. The thing is that every product has a different id. In this case "quantity_5dc9b23d9b5aa". So i had to do it for each product. Luckily i only had 8. :) |
@marcurares solution is what worked for me and it seems the more stable as it does not depend on methods out of pure html. Next code adds 06 units of variation 525 of product 524 to the cart ` BUY NOW ` |
Woocommerce -> settings -> products --> Add to cart behaviour |
If you are using Icegram Popup plugin, go to settings and switch off the "cache friendly - lazy load" options. This helped me with this same issue. |
@kubastas This issue has been fixed in 2.0.3 version of the Icegram plugin. Anyone who is facing the issue with this option is recommended to update the Icegram plugin to version 2.0.3 (or higher). |
add-to-cart URL should be like this, its works for me : ) |
When using "/cart?add-to-cart=ID" instead of "/cart
/
?add-to-cart=50" causes the item to be added twice.The first time is just before the redirect and then again after the redirect.
The text was updated successfully, but these errors were encountered: