【问题标题】:Basic Price Calculation with Shopify Liquid使用 Shopify Liquid 进行基本价格计算
【发布时间】:2019-04-10 18:43:48
【问题描述】:

我得到了一个计算方法,可以很好地计算出与 100 克的基本价格。

例子:

产品重量为 0.12 公斤(Shopify 后台中的重量以公斤为单位) 产品价格:29,95

使用我当前的公式,所有价格都使用以下代码与 100g 成比例:

<span id="perkg">{{ current_variant.price | times: 100.0 | divided_by: current_variant.weight | money }}</span>/100g

所以输出是:€24,96/100g

我现在想尝试的是,如果“current_variant.weight”> 0.25kg,那么输出应该是 1kg 而不是 100g。

例子:

产品重量 0,5kg。 产品价格:14,95

产量:29,90 欧元/1 公斤

任何想法如何在液体中解决这个问题?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    如果我理解正确的话是这样的:

    {%- if current_variant.weight > 0.25 -%}
      {%- assign price = current_variant.price | divided_by: current_variant.weight | money -%}
    {%- else -%}
      {%- assign price = current_variant.price | times: 100.0 | divided_by: current_variant.weight | money -%}
    {%- endif -%}
    
    {{ price }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多