I am wondering how you can clear the contents of your cart on page load using woocommerce.
I came accross how to add a clear cart button using by adding this in to f
the above didnt worked for me so i needed something that dont relies on WordPress conditional:
/*empty cart if user come to homepage*/
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
global $woocommerce;
if ($_SERVER['REQUEST_URI'] === '/') {
$woocommerce->cart->empty_cart();
}
}