Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Woocommerce empty cart before add new product to cart.
* 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 ) {
return $passed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment