Shopify购物车统计金额

释放双眼,带上耳机,听听看~!
    {% comment %} 计算购物车金额 {% endcomment %}
    {%- assign calculated_total_price = 0 -%}

    {%- for line_item in cart.items -%}
      {%- if line_item.requires_shipping -%}
        {%- assign calculated_total_price = calculated_total_price | plus: line_item.final_line_price -%}
      {%- endif -%}
    {%- endfor -%}

    {%- assign total_cart_discount = 0 -%}

    {%- for discount_application in cart.cart_level_discount_applications -%}
      {%- assign total_cart_discount = total_cart_discount | plus: discount_application.total_allocated_amount -%}
    {%- endfor -%}

    {%- assign calculated_total_price = calculated_total_price | minus: total_cart_discount -%}
    {% comment %} 计算购物车金额 {% endcomment %}


{% comment %} 写法与上面的一样 {% endcomment %}
{%- liquid
  assign calculated_total_price = 0

  for line_item in cart.items
    if line_item.requires_shipping
      assign calculated_total_price = calculated_total_price | plus: line_item.final_line_price
    endif
  endfor

  # We have to remove the cart level discount from the calculated amount

  assign total_cart_discount = 0

  for discount_application in cart.cart_level_discount_applications
    assign total_cart_discount = total_cart_discount | plus: discount_application.total_allocated_amount
  endfor

  assign calculated_total_price = calculated_total_price | minus: total_cart_discount
-%}

 

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

给TA打赏
共{{data.count}}人
人已打赏
Shopify主题开发Shopify功能开发独立站教程

使用自定义app调用shopify搜索代码

2024-1-3 15:36:43

Shopify功能开发

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

2022-11-28 21:50:44

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