Hi all
I currently have some cart attributes set up that are working great, but in reality they don’t make sense to appear for some products on my store.
Is there any way to set up my cart attributes so that they only appear when I have products with certain tags in the cart?
Many thanks in advance for any help on this.
Kind regards
Klayton
In cart page it looping cart item via line_item object. You can get the product tag by getting product object from that line_item, then get tags from that product
In the code, within the cart items loop, find the place where having the code for card attribute, wrap it with a condition. Something like this:
{% for item in cart.items %}
... other code here
{% if item.product.tags contains 'your-tag-here' %}
// place the properties code here
{% endif %}
... other code here
{% endfor %}
Thanks Quyen.
I’ve located the code you mention, but the cart attributes code is not in this part:
{% for item in cart.items %}
It is above this part of the code in this part:
I understand the issue here.
You can try this code. There are code changes on 2 places
{% assign showCartProp = false %}
{% for item in cart.items %}
{% if item.product.tags contains 'your-tag-here' %}
{% assign showCartProp = true %}
{% endif %}
{% endfor %}

