I have some special fees that get added along with every order (i’m using both an app and some other custom code). I’ve seen some examples where they dont work and dont get added, but I cant replicate it. All the fees have an “" on them like "ConvenienceFee”, so I have a simple protection built in which checks that at least one of the items in the cart contains an aseterik and it throws up an error message at checkout. I’ve realize this isnt sufficient. I have examples where one fee gets added and others do not. So I’d like to do this same check but check that it finds at least 3 items in the cart with an asterik.
So when “isFeeInCart” is true - it means no fee is in cart and I display an error message. So I need that to become false only after it finds the “*” three times.
Please help me with modification to this code to do this? Thank you.
{% assign isFeeInCart = true %}
{% for item in cart.items %}
{% if item.product.title contains "*" %}
{% assign isFeeInCart = false %}
{% endif %}
{% endfor %}
This was a great solution. I tested and it didnt work, it seemed the increment function didnt work - I used an alternative to the incrementing (I changed the variable name for my own reference) and it works perfect. Thanks so much for your help.