Liquid Help - Show Text on Product Page Based on a Product Tag

Tourist
15 0 3

I'm attempting to add a text section on to the product page to show the postage cost for items, based on whether a product tag is present - either FlatItem or SmallParcel. I've tried this in a few different places, but no text appears, so I wondered if it was the liquid code I have gotten wrong.

{% if product.tags contains "FlatItem" %}
£1.50 Delivery
{% endif %}
{% if product.tags contains "SmallParcel" %}
Delivery from £2.90
{% endif %}

I've read a few things, one says that it might only look at the first tag on the product and ignore the rest, another says this only works on collection pages so I'll need a different thing to product.tags or something about using 'join' but a lot I found is either outdated or unclear.

If anyone can help that would be amazing!

 

 

 

 

0 Likes

Hi Sophie,

Try to add this code:

{% for tag in product.tags %}
          {% if product.tags contains "FlatItem" %}
            £1.50 Delivery
            {% break %}
          {% elsif product.tags contains "SmallParcel" %}
          	Delivery from £2.90
          	{% break %}
          {% else %}

          {% endif %}
        {% endfor%}

Hope it helps!)

Best,
Arthur

Shopify subject matter expert | Founder at GenovaWebArt | Full-services shopify agency | info@genovawebart.com
1 Like
Tourist
24 0 0

thanks Arthur... that helped out a heap for me too

0 Likes