包含产品标签的任何产品的购物车字段中免责声明的液体编码



我目前正在cart.liquid中使用此代码。我已经在cart.template.liquid中尝试过,但我需要它出现在购物车容器的顶部或购物车中的产品附近,因为需要复选框。我是编码新手,所以请具体说明。我曾经https://ui-elements-generator.myshopify.com/pages/cart-attribute以生成所需的复选框部分。它说把它插入cart.liquid而不是cart.template.liquid。任何建议都会很棒

`{% for item in cart.items %}
{% if product.tag contains "delay" %}
<form>
<p class="cart-attribute__field">
<input type="hidden" name="attributes[I am aware that my order may have a 6 to 8-week 
shipping delay, since there are higher than normal ordering volumes.]" value="No">
<input required class="required" type="checkbox" name="attributes[I am aware that my 
order may have a 6 to 8-week shipping delay, since there are higher than normal ordering 
volumes.]" value="Yes"{% if cart.attributes["I am aware that my order may have a 6 to 8- 
week shipping delay, since there are higher than normal ordering volumes."] == "Yes" %} 
checked{% endif %}>
<label>I am aware that my order may have a 6 to 8-week shipping delay, since there are 
higher than normal ordering volumes.</label>
</p><br>Not interested in waiting, check out alternative options for immediate shipping.  
<a href="/collections/emergency-preparedness-survival-options"><b><i>SHOP NOW</i></b></a>
</form>
{% endif %}
{% endfor %}`

您使用的主题是什么?

在较新的主题中,主要的购物车内容位于cart.template.lique文件中,因此您处于正确的位置。

这里的问题是使用{% if product.tag contains "delay" %},因为产品对象不可用。相反,由于您正在循环浏览购物车项目,代码应该是:

{% if item.product.tags contains "delay" %}

这里发生的是item变量用于循环遍历所有购物车行项目。使用它,您就可以访问product.tags——注意,它是"标签",而不是"标签"——因为它是所有标签的数组。更多信息可以在这里看到。

希望能有所帮助!

最新更新