针对Shopify的特定供应商

发布于 2025-02-01 05:30:06 字数 439 浏览 1 评论 0原文

我需要针对特定​​的供应商,并且该供应商的产品是否缺乏库存禁用用户添加到购物车的能力(此部分的逻辑有效,只需专注于IF语句)即可。这是我到目前为止所拥有的:

{% assign isInStock = true %}
{% if product.vendor == 'PS-Stock' and current_variant.inventory_quantity < 1 %}
    {% assign isInStock = false %}
{% endif %}

当我运行{{isInstock}}以查看输出是什么时,我将获得真实。不确定产品供应商部分是否正确编写,因为我正在测试的产品具有0个库存数量,所以我知道语句正确的最后一部分

I need to target a specific vendor and if the product by this vendor is out of stock disable user ability to add to cart (logic for this part works, just need to focus on the if statement). Here is what I have so far:

{% assign isInStock = true %}
{% if product.vendor == 'PS-Stock' and current_variant.inventory_quantity < 1 %}
    {% assign isInStock = false %}
{% endif %}

When I run {{isInStock}} to see what the output is, i get true. Not sure if the product vendor part is wrote correctly as the product i am testing on has 0 inventory quantity so I know the last part of if statement is correct

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赤濁 2025-02-08 05:30:06

尝试其他部分

    {% assign product_qty = 0 %}
     {% for variant in product.variants %}
     {% if variant.inventory_quantity > 0 %}
     {% assign product_qty = product_qty | plus: variant.inventory_quantity %}
     {% endif %}
   {% endfor %}
   {% if product.vendor == 'abc' and product_qty > 0 %}
       working
   {%else%}
    not working
   {% endif %}

Try This with Else part

    {% assign product_qty = 0 %}
     {% for variant in product.variants %}
     {% if variant.inventory_quantity > 0 %}
     {% assign product_qty = product_qty | plus: variant.inventory_quantity %}
     {% endif %}
   {% endfor %}
   {% if product.vendor == 'abc' and product_qty > 0 %}
       working
   {%else%}
    not working
   {% endif %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文