[英]Shopify check for for tag [liquid]
{% for tag in product %}
{% if product.tags contains new %}
<span>Test</span>
{% endif %}
{% endfor %}
I need to look in products, and if a product has a tag called new
then display a span tag if not then nothing. 我需要查看产品,如果产品有一个名为
new
标签,那么如果没有则显示一个span标签。
For some reason, this piece of code doesn't work. 由于某种原因,这段代码不起作用。
This can do the job : 这可以完成工作:
{% for product in products %}
{% if product.tags contains "new" %}
<span>Test</span>
{% endif %}
{% endfor %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.