Created
July 6, 2019 12:18
-
-
Save renzoster/1429b81f6f4a44181a978cee5338ae84 to your computer and use it in GitHub Desktop.
Woocommerce empty cart before add new product to cart.
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
<?php | |
/** | |
* Empty cart. New product will be added. Works with WooCommerce 3.0+ | |
*/ | |
add_filter( 'woocommerce_add_to_cart_validation', 'custom_only_one_in_cart', 99, 2 ); | |
function custom_only_one_in_cart( $passed, $added_product_id ) { | |
wc_empty_cart(); | |
return $passed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment