shopify 产品列表页显示-优惠价格,节省金额和优惠百分比

释放双眼,带上耳机,听听看~!

shopify 产品列表页显示-优惠价格,节省金额和优惠百分比

如果优惠金额大于10显示金额,小于10显示百分比

{% assign savings_amount = product.compare_at_price | minus: product.price  %}
{%- if savings_amount > 1000 -%}
  {{ product.compare_at_price | minus: product.price | money }}<span style="padding-left:3px;">OFF</span>
{%- else -%} 
  {{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round }}%<span style="padding-left:3px;">OFF</span>
{%- endif -%}

 

方法1、直接输出

{{ product.compare_at_price | minus: product.price | money }}
{{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round }}%

方法2、或者如下,先声明字段,再引用


  {%- liquid 
  assign savings_percentage = compare_at_price | minus: price | times: 100 | divided_by: compare_at_price
  assign savings_amount = compare_at_price | minus: price | money 
  %}
  {{ savings_percentage }}% 
  {{ savings_amount }}

 

方法3、先判断选择再输出

  {%- liquid
    if label_count < 2 and settings.prod_reduction_show and cheapest_variant.compare_at_price > cheapest_variant.price
      if settings.prod_reduction_type == 'percent'
        assign amount = 1.0 | times: cheapest_variant.price | divided_by: cheapest_variant.compare_at_price
        assign amount = 1.0 | minus: amount
        assign amount = amount | times: 100.0 | round
        assign sale_label_text = 'products.labels.percent_reduction' | t: amount: amount
      else
        assign amount = cheapest_variant.compare_at_price | minus: cheapest_variant.price | money
        assign sale_label_text = 'products.labels.value_reduction_html' | t: amount: amount
      endif
      assign label_count = label_count | plus: 1
    endif
  -%}
  {%- if sale_label_text -%}
    <span class="product-label product-label--sale">
      <span>{{ sale_label_text }}</span>
    </span>
  {%- endif -%}

 

 

 

下面的代码来自shopify社区,计算有错误

Product Price: {{ product.price | money }}
Compare Retail Price: {{ product.compare_at_price_max | money }}
You save: {{ product.compare_at_price_max | minus:product.price | difference:product.compare_at_price_max | money }}
You save: {{ product.compare_at_price_max | minus:product.price | times:100 | divided_by:product.compare_at_price_max }}%

显示价格,比较零售价格,节省金额和百分比 – Shopify 社区

 

shopify 产品列表页显示-优惠价格,节省金额和优惠百分比

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
Shopify功能开发

shopify开发 加入swiper幻灯片section并且加入块blocks

2022-11-28 21:50:44

Shopify功能开发

shopify商品详情页复制优惠券功能

2023-1-4 12:13:05

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索