Check (inside the product template) if product is in certain category

Solved
New Member
3 0 0

Hi! I would like to add some text to my product pages (managed to do that part), but ONLY for certain categories. So in my product tenmplate, it should be like

 

{% if current_product is in cateroy_x %}

print my text...

{% endif %}

 

how do I do that? In the documentation, I only find how to list products of a category but not categories of a product.

 

Best wishes

Valentin

0 Likes

Success.

Shopify Partner
308 53 60

Hello Valentin,

 

Try to use this 


{% assign has_z = 0 %} {% for collection in product.collections %} {% if collection.handle== 'your-collection-handel' %} {% assign has_z = has_z | plus: 1 %} {% endif %} {% endfor %} {% if has_z >= 1 %} // print my text {% endif %}

  Thanks

Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
If helpful then please Like and Accept Solution.
If you happy and want to donate small, click here: Paypal
0 Likes
New Member
3 0 0

Thank you, that worked wonders!

0 Likes