【发布时间】:2021-09-22 17:53:26
【问题描述】:
我想获取当前所选变体的确切库存数量
我已经尝试过这段代码,但它返回了变量的所有数量。我只需要在购物车中选择的那个
{% endraw %}
{% assign product_qty = 0 %}
{% for variant in product.variants %}
{% if variant.inventory_quantity <= 0 %}
<p>{{variant.inventory_quantity}}</p>
{% assign product_qty = product_qty | plus: variant.inventory_quantity %}
{% endif %}
{% endfor %}
输出:
-3
0
0
0
【问题讨论】: