【发布时间】:2020-05-04 18:36:31
【问题描述】:
我正在使用 Shopify,并正在尝试添加选项,以便为所购买的产品添加礼品包装和手提箱。
我可以使用item.properties 询问用户的选择并将其显示在购物车中。
如果item.properties 设置为“礼品包装”或“手提箱”,我现在想向购物车添加其他产品。
这段代码放在product-template.liquid中但不起作用:
{% for property in item.properties %}
{% if property.last == "Gift Wrap" %}
<p>This would add gift wrap.</p>
<script>
jQuery.post('/cart/update.js', {
updates: {
32005672697928: 1
}
});
</script>
{% endif %}
{% if property.last == "Carry Strap" %}
<p>This would add carry strap.</p>
{% endif %}
{% endfor %}
{% endunless %}
【问题讨论】:
标签: shopify shopify-api