【问题标题】:Shopify (Liquid) if product has a tag, echo that tagShopify (Liquid) 如果产品有标签,则回显该标签
【发布时间】:2017-01-31 19:34:26
【问题描述】:

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

这让我得到了一个产品的所有标签...

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

我怎样才能回显符合“包含”条件的标签?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    你快到了。使用 forif 中迭代 product.tagscontains 以匹配 tag 与您的字符串文字标准。

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

    【讨论】:

    • 感谢您的快速回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 2022-07-25
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    相关资源
    最近更新 更多