Last active
June 28, 2016 15:19
-
-
Save junixdev/27fefc6d5f1da05b5365fc26ff3b822b to your computer and use it in GitHub Desktop.
force WooCommerce to only have one product in the cart session by emptying the cart session when a product is added
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 | |
add_filter( 'woocommerce_add_to_cart_product_id', 'junix_empty_cart_when_product_added' ); | |
function junix_empty_cart_when_product_added( $product_id ) { | |
if ( $product_id ) | |
WC()->cart->empty_cart(); | |
return $product_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment