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 functions.php add_action( 'init', 'woocommerce_clear_cart_url' ); function woocommerce_clear_cart_url() { global $woocommerce; if ( isset( $_GET['empty-cart'] ) ) { $woocommerce->cart->empty_cart(); } } But I was wondering how I'd go about triggering this on say, page load of the home...
Originally asked by user1370288 on Stack Exchange (stackoverflow) (CC BY-SA 3.0).