FROM CACHE - en_header

if statement on product tags

Shopify Partner
7 0 1


I am not much of a coder, but am in need of a very time critical change

I have had to change the architecture of my site last minute, and now my front page collection (only has 3 products) needs to link to a unique collection of products  rather than a product


I thought the easiest way to do this (as its very static) would be to create an if statement and use product tags


see below


      {% if item.product.tag == littlehands %}
      <a class="grid-view-item__link" href="">
      <img src=""/>  </a> 
      {% endif %} 
      {% if item.product.tag == bighands %}
      <a class="grid-view-item__link" href="">
      <img src=""/>  </a> 
      {% endif %}
      {% if item.product.tag == family %}
      <a class="grid-view-item__link" href="">
      <img src=""/>  </a> 
      {% endif %}

However the outcome is 3 buttons linking to 3 different areas instead of 1. 

Replies 5 (5)
Shopify Expert
10898 191 2185

Try something more like:

{% if item.product.tags contains "littlehands" %}


★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. ★
Shopify Partner
7 0 1

Thanks Jason


I sorted it out, needed a for loop first, and then the if's off the results of the for.


New Member
5 0 0

Hi Roxanne,

I think I am attempting to do a simliar thing, but can't figure it out. Can you share the code you wrote with the loop to do this, thank you!

4 0 1

This works

I put this in the product-template.liquid code and am using App metafield guru to set the message I want in the product.metafields.Info.Shipping field of the product metafield

{% assign has_delivery_tag = false %}
{% for tag in item.product.tags %}

{% if tag == 'Delivery' %}
{% assign has_delivery_tag = true %}
{% break %}
{% endif %}
{% endfor %}
{% if has_delivery_tag == false %}
<h6><p style="color:purple;font-size: 22px">Delivery Information:-<BR>
{{ product.metafields.Info.Shipping }} </p></h6></style>
{% endif %}

Shopify Partner
11 0 0

thank you ,its helpfull for me