我希望有人能帮我这个忙。我试图显示一个交付状态的某些标签的项目,是设置为超卖。
首先检查产品是否带有“香水”标签,然后看看库存是否在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>发布于 2020-12-16 04:22:41
我会这样处理:
{% 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。
https://stackoverflow.com/questions/65311225
复制相似问题