Skip to content

Instantly share code, notes, and snippets.

@INDIAN2020
Forked from yanknudtskov/functions.php
Created June 18, 2018 06:11
Show Gist options
  • Save INDIAN2020/515fe73762d0a1f5a4ed0864d10457a3 to your computer and use it in GitHub Desktop.
Save INDIAN2020/515fe73762d0a1f5a4ed0864d10457a3 to your computer and use it in GitHub Desktop.
Clear the #woocommerce #cart with a query string parameter
<?php
/*
* If you add ?clear-cart to the URL the cart will be emptied
*/
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment