Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Last active April 19, 2018 15:21
Show Gist options
  • Save WebEndevSnippets/5709625 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/5709625 to your computer and use it in GitHub Desktop.
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