0
votes

I'm trying to find product tags that meet a condition, and then display those tag(s).

This gets me all the tags for a product...

{% for tag in product.tags %}
{% if product.tags contains '336699' %}
{{ tag }}
{% endif %}
{% endfor %}

How can I just echo the tags that meet the 'contains' criteria?

1

1 Answers

4
votes

You're almost there. Use for to iterate the product.tags and contains within a if to match tag with your string literal criteria.

{% for tag in product.tags %}
    {% if tag contains '336699' %}
        {{ tag }}
    {% endif %}
{% endfor %}