Woocommerce Empty cart functions not working
-
I have a WordPress – Woocommerce Website.On my website i added empty cart button by using following code.
`add_action( ‘init’, ‘woocommerce_clear_cart_url’ );
function woocommerce_clear_cart_url() {
global $woocommerce;
if ( isset( $_GET[’empty-cart’] ) ) {
echo “test”;
//exit;
$woocommerce->cart->empty_cart(true);
}
}
add_action( ‘woocommerce_cart_actions’, ‘patricks_add_clear_cart_button’, 20 );
function patricks_add_clear_cart_button() {
echo “<a class=’button’ href=’?empty-cart=true’>” . __( ‘Empty Cart’, ‘woocommerce’ ) . “</a>”;
} `This code is not working when user logged in.When user logged in apply the empty cart button then cart is not empty.This code only working at the time of user logged out.I am using latest version of woocommerce 3.2.2.
I can’t understand how to fix.
- The topic ‘Woocommerce Empty cart functions not working’ is closed to new replies.