Skip to main content

Clear Cart with a Link in Woocommerce

By July 20, 2020August 3rd, 2020No Comments

I needed a quick and easy way to clear the cart on the fly if needed. This snippet doesn’t disappoint πŸ™‚ Simply append ?clear-cart to the URL to clear the cart – put it in an anchor link if you need it πŸ™‚

add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
	if ( isset( $_GET['clear-cart'] ) ) {
		global $woocommerce;

Thanks Sarathlal N

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton