【问题标题】:Adding all output of a variable in liquid在液体中添加变量的所有输出
【发布时间】:2019-12-15 13:37:36
【问题描述】:

这是一个为单个产品订单输出项目数量的变量,

`{{item.qty}}`

output= product 9 = 2pcs

而且输出很正常, 但是当订购多个产品时,它会输出订购的每个产品的每个数量,

Product 1 = 2pcs
product 2 = 7pcs
product 3 = 9pcs

如何将每个输出添加到一个总数中?

【问题讨论】:

  • 你能把你的问题说得更清楚吗?我不明白。
  • {% cycle {{item.qty}} %}//output 1pc, 1pc 这是我提取每个项目数量的代码,只想知道如何添加它抛出的每个输出,

标签: variables liquid


【解决方案1】:

如果你的正面是这样的:

---
title: Product 1
qty: 3
---

你的布局应该是这样的:

{% assign siteproducts = site.products | sort: 'qty' %}
{% for item in siteproducts %}

  {{ title }} = {{ qty }}pcs

{% endfor %}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 2011-11-07
    • 2017-10-29
    • 2020-06-15
    • 1970-01-01
    相关资源
    最近更新 更多