Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plugin: Clear Cart for WooCommerce
<input type="submit" class="button" name="clear-cart" value="<?php _e('Empty Cart', 'woocommerce'); ?>" />
/**
* Clear Cart for WooCommerce
*/
add_action( 'init', 'we_woocommerce_clear_cart_url' );
function we_woocommerce_clear_cart_url() {
global $woocommerce;
if( isset($_REQUEST['clear-cart']) ) {
$woocommerce->cart->empty_cart();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment