【问题标题】:How do I show a tag to represent multiple products? Shopify Liquid如何显示一个标签来代表多个产品? Shopify 液体
【发布时间】:2015-03-27 17:41:32
【问题描述】:

您好,感谢您阅读我的帖子!

我有一个包含多个产品的集合。在自定义集合模板上,我只想显示包含多个产品的标签 (或者当该集合中的多个产品具有相同标签时)

我认为它会是这样的:

  {% for tag in collection.all_tags %}
    {% if tag.product.size >= 1 %}
      has more than 1 product.  
    {% endif %}
  {% endfor %}

【问题讨论】:

    标签: logic output shopify liquid


    【解决方案1】:

    我已经回答了herehere 的类似问题。

    你想要这样的东西:

    {% for tag in collection.all_tags %}
        {% assign products_count = 0 %}
        {% for product in collection.products %}
            {% if product.tags contains tag %}
                {% assign products_count = products_count | plus: 1 %}
            {% endif %}
        {% endfor %}
    
        {% if products_count > 1 %}
            {{ tag }}
        {% endif %}
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多