miguel.nz

Check if a product belongs to a Collection or has a Tag in Shopify

July 16, 2021   |   1 minute read.

The following examples will help you to check if a product belongs to a custom collection or they have a certain tag:

{% assign in_coming_soon_collection = false %}
{% for collection in product.collections %}
  {% if in_coming_soon_collection == false and collection.title == 'Coming Soon' %}
    {% assign in_coming_soon_collection = true %}
  {% endif %}
{% endfor %}

Checking if product has a tag. Mind that tags are case sensitive and spacing matters.

{% for tag in product.tags %}
  {% if tag contains 'silk' %}
    {{ tag }}
  {% endif %}
{% endfor %}

From: https://stackoverflow.com/questions/41966028/shopify-liquid-if-product-has-a-tag-echo-that-tag