我想检查我的结账单中的商品是否是集合的一部分(或者它是否具有特定标签).
这是我试图检查是否有产品的"尝试"
{% for item in cart.items %}
{% if item.product.collections == "SampleProduct" %}
<p>Enjoy your Product</p>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
谢谢
如果你想检查你的产品是否在特定的系列中,你需要这样的东西:
{% for item in cart.items %}
{% assign found_collection = false %}
{% for collection in item.product.collections %}
{% if found_collection == false and collection.title == 'SampleProduct' %}
{% assign found_collection = true %}
{% endif %}
{% endfor %}
{% if found_collection %}
<p>Enjoy your Product</p>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
或者,如果要检查标记,请使用:
{% for item in cart.items %}
{% if item.product.tags contains 'SampleProduct' %}
<p>Enjoy your Product</p>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅包含运算符的Shopify Wiki页面.
| 归档时间: |
|
| 查看次数: |
2655 次 |
| 最近记录: |