[英]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.