我让shopify显示正确的库存数量,但前提是我刷新了每个变体的页面。例如:我有12个变量,数量从1到8不等,但如果我单击variant-1,它会显示我有两个变量。如果我点击variant-6,它仍然显示I have 2,除非我点击刷新页面,然后它将显示正确的库存数量。我正在尝试解决这个问题,所以当我改变变量时,价格和数量一起更新,但不确定如何更新。你能帮帮我吗?
这是我使用的代码
{% comment %} Inventory tracking on product page {% endcomment %}
<div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
We have {{ current_variant.inventory_quantity }} in stock.
{% else %}
This product is available.
{% endif %}
</div>它在第121行:product-template.iquid
发布于 2020-05-21 17:20:49
您的product-template.liquid只会影响页面加载时可见的内容-它不是动态的,而且liquid无法知道加载后页面上发生了什么事件。
为了实现您正在寻找的内容,您将需要一些客户端JS来观察所选变体的变化,并分别更新副本。
https://stackoverflow.com/questions/61916203
复制相似问题