首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何根据shopify中的标签和可用库存显示不同的传递消息?

如何根据shopify中的标签和可用库存显示不同的传递消息?
EN

Stack Overflow用户
提问于 2020-12-15 17:58:07
回答 1查看 129关注 0票数 1

我希望有人能帮我这个忙。我试图显示一个交付状态的某些标签的项目,是设置为超卖。

首先检查产品是否带有“香水”标签,然后看看库存是否在0以上或以下。

我从堆栈上的几个例子中拼凑了这段代码(我对此非常陌生)

代码语言:javascript
复制
{% 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 %}

当我刷新产品时,我得到的只有显示负库存计数的其他输出,我尝试过不同的标记,也尝试过.

代码语言:javascript
复制
{% if collection.handle== 'perfume' %}

谢谢KOOSA

下面是您的代码的编辑版本

它显示了我的产品页面上这两个规则的输出。

代码语言:javascript
复制
        <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 %}

我想这就是答案,谢谢你的帮助:)

代码语言:javascript
复制
        <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-16 04:22:41

我会这样处理:

代码语言:javascript
复制
{% 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65311225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档