I’ve been working with a “Trial Product” in a WooCommerce store which needs to be the only item in the cart during checkout due to shipping requirements (and because it doesn’t make sense to order a trial if you’re also going to order the actual product).
To make this clear to the customer, I’ve restricted what can be added to the cart in specific situations:
1) If the “Trial Product” is already in the cart, additional products should not be added. WooCommerce will instead display a notice asking the customer to remove the “Trial Product” from their cart if they wish to add different products.
2) If products are already in the cart, and the customer attempts to add the “Trial Product”, a notice will display asking the customer to remove the other items from their cart first.
Here’s what the code looks like:
[gist id=”ff6fa702e308aa07d9cfcd206aac3006″ oembed=”1″]