Shopify (Liquid) 如果产品有标签,回显该标签

Shopify (Liquid) if product has a tag, echo that tag

我正在尝试查找符合条件的产品标签,然后显示这些标签。

这让我获得了产品的所有标签...

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

如何只回显符合'contains'条件的标签?

你快到了。使用 for to iterate the product.tags and contains within a iftag 与您的字符串文字条件相匹配。

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