Tom Moceri

URL Parameter to Clear the Cart

When putting together bundles or products that go together (using the /?add-to-cart=73,82 url parameters), it would be very helpful to have a “clear the cart” options. For example /?clear_cart?add-to-cart=73,82. Sample code… add_action( ‘init’, ‘woocommerce_clear_cart_url’ ); function woocommerce_clear_cart_url() { if ( isset( $_GET[‘clear-cart’] ) ) { global $woocommerce; $woocommerce->cart->empty_cart(); } }

Scroll To Top

Get Help!

Submit your question and Spence will get back to you quickly via Email!