FROM CACHE - en_header

Clear cart when only contains free gift

4 0 1

I am offering an item as a free gift when purchasing with a particular product. But if the buyer remove this certain product, and the cart will only contain the free gift, i would like to disable customer from checking out. 


Although this can be done via an automatic discount, only one rule can be applied one time. So if i want to run a few, how can I get this done? 


I am not that familiar with script, so I am thinking when customer click to remove other items from the cart, it will clear the entire cart when the cart contains the free gift, but it didn't work as expected.

{% if item.product.title contains 'FREE' %}
window.location = "/cart";
{%- endif -%}


Reply 1 (1)
Shopify Expert
77 4 10

Did you ever solve this? 

On The Road Shopify Agency
Helping Shopify stores to become greater with purpose behind design.