[英]Wordpress Woocommerce product is being added to cart on page refresh
我在使用woocommerce时遇到了问题。
将产品添加到购物车后,浏览器中的链接变为link /?add-to-cart = 72 ,如果我刷新页面,产品将再次添加到购物车中。
每次刷新都会在购物车中添加产品。 我禁用了所有插件,除了woocommerce,仍然是相同的。
关于如何解决这个问题的任何想法?谢谢。
我曾经遇到过同样的问题,这里是您应该添加到主题的functions.php
文件或自己的自定义插件的代码:
add_action('add_to_cart_redirect', 'resolve_dupes_add_to_cart_redirect');
function resolve_dupes_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'));
}
当用户将产品添加到购物车时,它将添加重定向。 我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.