Checking if a product belongs to a collection

You can check if a product belongs to a specific collection. This code will work on a product page that's using the shop:product action.


{% if product.collections.count %}
  {% for collection in product.collections if collection.name == 'Featured Collection' %}
      <!-- This product belongs to the Featured Collection! -->
  {% endfor %}
{% endif %}

Note that this checks against the collection's name which is case-sensitive.