我希望有人可以帮助我。我想显示设置为超售的某些带标签物品的交货状态。
首先,我正在查看产品是否带有“香水”标签,然后库存是否高于或低于0
我已经从堆栈上的几个示例中拼凑了这段代码(对此非常新)
{% if product.tags contains 'perfume' and current_variant.inventory_quantity <=0 %}
<div>No inventory, customer allowed to order but has long wait' = Out of Stock please allow 20-30 days for delivery</div>
{% elsif product.tags contains 'perfume' and current_variant.inventory_quantity <=1 %}
<div>No inventory, but customer allowed to order' = Order now for delivery within 7 days</div>
{% else %}
<div>Items in stock' = We have {{ current_variant.inventory_quantity }} in stock for delivery in 4-6 days.</div>
{% endif %}
当我刷新产品时,得到的所有其他输出都显示出库存为负,我尝试了不同的标签,还尝试了...
{% if collection.handle== 'perfume' %}
感谢KOOSA
这是你的代码的编辑版本
它在我的产品页面上显示了这两个规则的输出
<div class="productShippingInformation">
{% if product.tags contains 'Discount Enabled' and current_variant.inventory_policy == 'continue' %}
{% elsif current_variant.inventory_quantity >= 1 %}
Delivered in 4-6 days.
{% endif %}
{% if current_variant.inventory_quantity <= 0 %}
<b>Delivered in 10-14 days.</b>
{% endif %}
{% if product.tags contains 'Perfume & Aftershave' and current_variant.inventory_policy == 'continue' %}
{% if current_variant.inventory_quantity <= 0 %}
<div><b>Delivery in 2021.</b> please allow 20-30 days for delivery</div>
{% elsif current_variant.inventory_quantity >= 1 %}
<div>Order now for delivery within 7 days</div>
{% endif %}
{% else %}
<div>in stock for delivery in 4-6 days.</div>
{% endif %}
<div class="productShippingInformation">
{% if product.tags contains 'Discount Enabled' and current_variant.inventory_policy == 'continue' %}
{% elsif current_variant.inventory_quantity >= 1 %}
Delivered in 4-6 days.
{% endif %}
{% if current_variant.inventory_quantity <= 0 and product.tags contains 'Discount Enabled'%}
<b>Delivered in 10-14 days.</b>
{% endif %}
</div>
<div class="productShippingInformation">
{% if product.tags contains 'Perfume & Aftershave' and current_variant.inventory_policy == 'continue' %}
{% if current_variant.inventory_quantity <= 0 %}
<div><b>Delivery in 2021.</b> please allow 20-30 days for delivery</div>
{% elsif current_variant.inventory_quantity >= 1 %}
<div>Order now for delivery within 7 days</div>
{% endif %}
{% endif %}
</div>
我会这样处理:
{% if product.tags contains 'perfume' and current_variant.inventory_policy == 'continue' %}
{% if current_variant.inventory_quantity <= 0 %}
<div>Out of Stock please allow 20-30 days for delivery</div>
{% elsif current_variant.inventory_quantity >= 1 %}
<div>Order now for delivery within 7 days</div>
{% endif %}
{% else %}
<div>We have {{ current_variant.inventory_quantity }} in stock for delivery in 4-6 days.</div>
{% endif %}
看来你的主要问题是current_variant.inventory_quantity <= 1
什么时候应该current_variant.inventory_quantity >= 1
辉煌-谢谢!我确实有一个小问题,当我运行此规则时,我希望根据标签使用两种类型的消息传递,因此我将其加倍,并且该规则似乎在所有产品上都显示了...
.i已将代码添加到我的原始问题中,因为它不允许我发表评论
@Anthony-没问题,请记住将此答案标记为正确!