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 page (if you could specifiy the exact page that would be great, but even the home page would be useful)
Any ideas? Thanks!
$woocommerce->cart->empty_cart();
– Bolger