I have a problem using woocommerce.
After I add a product to cart the link in browser becomes link/?add-to-cart=72,and if i refresh the page the product is added again in cart.
Every refresh addes the product in cart. I disabled all plugins except woocommerce and still the same.
Any ideea on how to fix this ?Thank You.
I had the same issue once, here is the code that you should add to your theme’s functions.php
file, or to your own custom plugin:
add_action('add_to_cart_redirect', 'cipher_add_to_cart_redirect');
function cipher_add_to_cart_redirect($url = false) {
// If another plugin beats us to the punch, let them have their way with the URL
if(!empty($url)) { return $url; }
// Redirect back to the original page, without the 'add-to-cart' parameter.
// We add the `get_bloginfo` part so it saves a redirect on https:// sites.
return get_bloginfo('wpurl').add_query_arg(array(), remove_query_arg('add-to-cart'));
}
It will add a redirection when users added products to their cart. I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With