0

我目前在带有液体的页面中有以下变量:

{% assign tagQty = 0 %}

我想遍历一些购物车项目并添加到这个变量中。我需要跟踪每个额外的数量,并且变量需要包含总数。这是我的尝试:

{% for item in cart.items %}
  {% for tag in item.product.tags %}
    {% if tag == 'Speicific-Tag' %}
      {% tagQty = tagQty | plus: item.quantity %}
    {% endif %}
  {% endfor %}
{% endfor %}

上面给出了一个错误,因为这是无效的:{% tagQty = tagQty | plus: item.quantity %} 我也试过:{{ tagQty = tagQty | plus: item.quantity }}这也是无效的。

我可以重新分配 tagQty 但这违背了目的,因为我需要收集这个特定产品标签的总数来显示它。知道我怎么能做到这一点吗?

4

1 回答 1

0

好的,我发现我必须重新分配变量。

{% assign tagQty = tagQty | plus: item.quantity %}
于 2022-01-22T01:26:56.490 回答