Last active
April 19, 2018 15:21
-
-
Save WebEndevSnippets/5709625 to your computer and use it in GitHub Desktop.
Plugin: Clear Cart for WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="submit" class="button" name="clear-cart" value="<?php _e('Empty Cart', 'woocommerce'); ?>" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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