【问题标题】:How can add multiple collection in shopify liquid for loop?如何在shopify Liquid for循环中添加多个集合?
【发布时间】:2018-01-28 15:08:30
【问题描述】:

我想展示从主题设置中选择的集合中的产品。 这是我的代码:

{% assign col1 = collections[settings.collection1] %}
{% assign col2 = collections[settings.collection2] %}
{% assign col = [col1, col2] %}
   {% for product in col .products %}
     {{ product }}
   {% endfor %}

【问题讨论】:

    标签: ruby-on-rails e-commerce shopify liquid


    【解决方案1】:

    你的代码应该是这样的

       {% for i in (1..2) %}
       {% capture col %}collection{i}{% endcapture %}
    
       {% for product in collecitons.settings[col] %}
        {{product}}
       {% endfor %}
    
       {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 2012-04-14
      相关资源
      最近更新 更多