Shopify 库存在产品页面上显示输出
Shopify Inventory Display Output on Product Page
我一天中的大部分时间都在建立一个新的 shopify 网站——这是我对 shopify 的第一次体验。其中大部分都非常简单,但在产品页面上显示库存时,我发现自己有些困惑。我用的是出道主题,用编辑器更新'product-template.liquid'
浏览文档后,我添加了以下内容;
{% 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 for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
</div>
但是,目前返回 'out of stock' 实际上有货的商品。此外,我希望实现但找不到文档的是;
- 'Items in stock' = 我们有 {{ current_variant.inventory_quantity }} 库存,您可以在下午 2 点前下单,次日送达。
- 'No inventory, but customer allowed to order' = 现在下单7天内发货
- 'No inventory, customer not allowed to order' = 缺货
非常感谢任何指点!
我对这行代码有点疑惑:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
您要检查的是您是否正在使用 shopify 跟踪库存,以及是否在管理面板中选中了变体选项命令以允许人们即使缺货也可以订购。我假设后者已被检查,因此它总是返回 else。
如果没有库存,则不会显示任何内容,因为这条线:
div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
因为我不确定你打算如何区分缺货和缺货可以在 7 天内订购。因为库存跟踪器中没有任何东西可以让您输入进货产品(据我所知)。如果你很想手动输入这个,你可以去 product.template.liquid 找到 Ctrl + F
{% unless current_variant.available %}
第二个是售完代码的地方
并通过添加和删除标签对其进行编辑(使用 noOrder 和 noStockCanOrder 作为示例标签)
{% if product.tags contains 'noOrder' %}
<div>No inventory, customer not allowed to order' = Out of Stock</div>
-Insert Current out of stock code here-
{% elsif product.tags contains 'noStockCanOrder' %}
<div>No inventory, but customer allowed to order' = Order now for delivery within 7 days</div>
-Insert Current in stock code here-
{% else %}
<div>Items in stock' = We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.</div>
-Insert Current in stock code here-
{% endif %}
你可能需要稍微尝试一下,因为我从来没有完全按照你的要求做过,但理论应该是合理的,它应该让你接近你想要的,你可以从那里编辑它。
你有:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
这将针对以下任一情况显示 'Out-of-Stock' 消息:
inventory_management
是 blank
(默认值)
inventory_policy
是 continue
你可能想要的是这样的:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
{% comment %}
We care about inventory on this product - is there any in stock?
{% endcomment %}
(% if current_variant.inventory_quantity > 0 %}
We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
{% else %}
{% comment %}
Any code/messages we might want for products where we don't care about inventory
{% endcomment %}
{% endif %}
我一天中的大部分时间都在建立一个新的 shopify 网站——这是我对 shopify 的第一次体验。其中大部分都非常简单,但在产品页面上显示库存时,我发现自己有些困惑。我用的是出道主题,用编辑器更新'product-template.liquid'
浏览文档后,我添加了以下内容;
{% 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 for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
</div>
但是,目前返回 'out of stock' 实际上有货的商品。此外,我希望实现但找不到文档的是;
- 'Items in stock' = 我们有 {{ current_variant.inventory_quantity }} 库存,您可以在下午 2 点前下单,次日送达。
- 'No inventory, but customer allowed to order' = 现在下单7天内发货
- 'No inventory, customer not allowed to order' = 缺货
非常感谢任何指点!
我对这行代码有点疑惑:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
您要检查的是您是否正在使用 shopify 跟踪库存,以及是否在管理面板中选中了变体选项命令以允许人们即使缺货也可以订购。我假设后者已被检查,因此它总是返回 else。
如果没有库存,则不会显示任何内容,因为这条线:
div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
因为我不确定你打算如何区分缺货和缺货可以在 7 天内订购。因为库存跟踪器中没有任何东西可以让您输入进货产品(据我所知)。如果你很想手动输入这个,你可以去 product.template.liquid 找到 Ctrl + F
{% unless current_variant.available %}
第二个是售完代码的地方 并通过添加和删除标签对其进行编辑(使用 noOrder 和 noStockCanOrder 作为示例标签)
{% if product.tags contains 'noOrder' %}
<div>No inventory, customer not allowed to order' = Out of Stock</div>
-Insert Current out of stock code here-
{% elsif product.tags contains 'noStockCanOrder' %}
<div>No inventory, but customer allowed to order' = Order now for delivery within 7 days</div>
-Insert Current in stock code here-
{% else %}
<div>Items in stock' = We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.</div>
-Insert Current in stock code here-
{% endif %}
你可能需要稍微尝试一下,因为我从来没有完全按照你的要求做过,但理论应该是合理的,它应该让你接近你想要的,你可以从那里编辑它。
你有:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
这将针对以下任一情况显示 'Out-of-Stock' 消息:
inventory_management
是blank
(默认值)inventory_policy
是continue
你可能想要的是这样的:
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
{% comment %}
We care about inventory on this product - is there any in stock?
{% endcomment %}
(% if current_variant.inventory_quantity > 0 %}
We have {{ current_variant.inventory_quantity }} in stock for next-day delivery when you order by 2pm.
{% else %}
Out of Stock
{% endif %}
{% else %}
{% comment %}
Any code/messages we might want for products where we don't care about inventory
{% endcomment %}
{% endif %}