Focusing on managing products, variants, and collections through the API.
Hi,
I'm not sure if this is the correct place to ask this question... but I I am trying to get a badge to show if the product belongs to a certain collection. (Call this Discountcat) This seems to be working for some of the products, but not for all of the products that it should be.
I have figured out by adding this code that Shopify doesn't think the product belongs to the Discountcat collection even though it is showing up in the collection and is visible in the admin system
{% for collection in product.collections %}
{{ collection.title }}
{% endfor %}
It shows that the product is in a few collections, except for the Discountcat one...even though it shows up?!
Has anyone else encountered this?
Code for badge
{% for collection in product.collections %}
{% if collection.title contains 'Discountcat' %}
<div class="badge">offer</div>
{% endif %}
{% endfor %}
Thanks in advance
Thank you for your reply.
The items are being auto added to the collection if they meet 3 criteria (product type equal to ,product tag equal to and title does not contain x)