-
-
Save INDIAN2020/515fe73762d0a1f5a4ed0864d10457a3 to your computer and use it in GitHub Desktop.
Clear the #woocommerce #cart with a query string parameter
This file contains hidden or 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
| <?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