Empty cart button not working.
-
I have a function that lets me empty the cart with a click of a button. Since the latest update (I belive) this is not working anymore. I’ve been looking in the changelog but can’t really find the reason as to why it’s not working anymore. Is there something I’ve missed? Any help would be greatly appreciated.
This is the function:
add_action('wp_loaded', 'woocommerce_empty_cart_action', 20); function woocommerce_empty_cart_action() { if (isset($_GET['empty_cart']) && 'yes' === esc_html($_GET['empty_cart'])) { WC()->cart->empty_cart(); $referer = wp_get_referer() ? esc_url(remove_query_arg('empty_cart')) : wc_get_cart_url(); wp_safe_redirect($referer); } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Empty cart button not working.’ is closed to new replies.