shopify 如何根据标签和可用库存显示不同的送货信息?

How to display different delivery messages depending on tag and available stock in shopify?

我希望有人能帮我解决这个问题。我正在尝试显示某些设置为超卖的带标签商品的送货状态。

我首先查看产品是否标有 'perfume',然后查看库存是否高于或低于 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 %}

当我刷新产品时,我得到的只是显示负库存的 else 输出,我尝试了不同的标签,也尝试了...

{% 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