By default the URL add-to-cart=xxx redirects to the cart or send by AJAX. So no problem when refreshing the page. Maybe you are doing something customized, maybe in your theme or in a plugin that is causing it.
Please test with other theme and test the installed plugins too.
We haven’t changed anything but we just noticed this problem. We aren’t developers and we certainly don’t do any javascript or AJAX programming.
I found this fix – https://github.com/woothemes/woocommerce/commit/12a248563715eccb1ca916cf9b35d841aceae4ca, which seems to have resolved the issue, but as for what might have changed, I have no idea.
I agree with Claudio, it sounds like there is something else that is catching a redirect or possibly caching.
Exactly how did you apply the “fix”? That was a code commit from a previous version of WooCommerce.
Sorry for missing you question. I added the the code in the fix above to class-wc-form-handler.php. Incidentally, I just had the same problem with a different site; the same fix worked.
Does this happen when clicking the add to cart button, or when manually typing in that url?
Also, why not upgrade WooCommerce? 🙂
The ‘Add to cart’ hyperlink looks something like this /shop/?add-to-cart=xxx. When you click the ‘Add to cart’ link the URL stays in the address bar so if the page is refreshed another item is added to the cart. The fix removes /shop/?add-to-cart=xxx from the address bar so stopping the erroneous addition of items to the cart.
The latest site to have the issue is running WP v4.5.3 and WooCommerce v2.6.4. We are using a theme called GoodStore v3.0.6 (the latest version) with a child theme.
Just found out that the previous core code that removed the query string broke some plugins.
So you can use that fix on your site as long as it isn’t causing any plugin conflicts 🙂
Ah, so the fix I am using used to be code in the core plugin but was removed as it broke some plugins?