Shopify 液体:未定义购物车模板变体

Shopify liquid : cart-template variant is not defined

我只是允许结帐购买缺货产品。当客户想要购买库存小于零的产品并点击 ajax 购物车中的查看购物车时,我只想显示消息“6 月 7 日前发货”。在 cart-template.liquid 中。我应用了下面给出的逻辑。如果需要完整代码准备分享。

{% if variant.inventory_quantity < 1%}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{{variant.inventory_quantity}}
{% endif %}
<script>console.log(variant.inventory_quantity)</script>

当我在没有 if 条件的情况下在 cart-template.liquid 中打印消息时,我可以看到此消息。我发现它没有在 {{}} 中打印任何内容,还检查了 console.log 给出了错误,因为 variant is not defined 我的查询是我需要手动定义 variant 吗?如果是怎么办?或者需要使用不同的液体变量来检查小于零的产品库存数量? 让我知道是否需要更多。谢谢。

我已经开始打印所有变体变量。我只是简单地在 variant.inventory_quantity 之前添加了 item,这节省了我的时间。

{% if item.variant.inventory_quantity < 1 %}
<p id="dispatch" style="color: #f48c21">Will be dispatched by June 7</p>
{% endif %}