Skip to content

Instantly share code, notes, and snippets.

@yratof
Forked from kloon/gist:4541017
Created November 22, 2017 16:12
Show Gist options
  • Save yratof/779cb04c4d238169c3b06867f7c50bc1 to your computer and use it in GitHub Desktop.
Save yratof/779cb04c4d238169c3b06867f7c50bc1 to your computer and use it in GitHub Desktop.
WooCommerce Clear Cart via URL
// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment