Allow only one product into woocommerce cart


add_filter( ‘woocommerce_add_to_cart_validation’, ‘aviweb_only_one_in_cart’, 99, 2 );

function aviweb_only_one_in_cart( $passed, $added_product_id ) {
// empty cart and new item will replace previous
wc_empty_cart();
return $passed;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s