Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shopify If in collection then display this

Tags:

shopify

I am trying to write a simple if statement, but always struggle with shopify's system.

Essentially I want it to do this:

{% if collection.product == 'discontinued' %} This Product is Discontinued. {% endif %}

If it's in this collection, then display this text/html. Otherwise it wouldn't display anything. This would be in the product.liquid template.

Any ideas?

like image 209
Crystal Groves Avatar asked Oct 16 '25 18:10

Crystal Groves


1 Answers

This is what ended up working:

{% for c in product.collections %}
{% if c.handle == "discontinued" %}
This product is Discontinued 
{% endif %}
{% endfor %}
like image 95
Crystal Groves Avatar answered Oct 18 '25 16:10

Crystal Groves