Skip to content

Instantly share code, notes, and snippets.

@kurtschlatzer
Forked from WebEndevSnippets/cart.php
Created April 19, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtschlatzer/ebaf35cd3e5c033c7cc30cf83fbb9006 to your computer and use it in GitHub Desktop.
Save kurtschlatzer/ebaf35cd3e5c033c7cc30cf83fbb9006 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