Limit cart to a single product
-
I am creating an online store which should only allow a single product in the cart, that is, there is no possibility to add a second product. I found the following code that makes this possible:
add_filter( 'woocommerce_add_cart_item_data', 'mk_only_one_item_in_cart', 10, 1 ); function mk_only_one_item_in_cart( $cartItemData ) { wc_empty_cart(); return $cartItemData; }
So far so good, but one of the products in the store requires the addition of a second product, in other words, a forced sale. Would it be possible to modify this code so that this particular product would allow two products in the cart? I don’t know if I’m making myself clear.
Thank you very much!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Limit cart to a single product’ is closed to new replies.