【问题标题】:Making a custom collection in shopify liquid - liquid在 shopify 液体 - 液体中制作自定义系列
【发布时间】:2021-09-04 18:24:59
【问题描述】:

我想根据一些条件场景在 collection.liquid 中创建一个自定义集合,为此我应用了concatappendjoin,但问题是它返回ProductDropProductDropProductDropProductDrop...LazyProductDropCollectionLazyProductDropCollection的产品。以下是代码sn -p

{% assign custom_products = '' %}
{% for product in collections["paneer-easy-indie-bowls"].products %}
  {% assign custom_products = custom_products | append: product %}
{% endfor %}

我尝试了joinconcat 而不是追加,但返回ProductDropProductDropProductDropProductDrop...

{% assign custom_products = custom_products | concat: product %}

然后我尝试了以下方法:

{% capture custom_products %}
  {% for product in collections["paneer-easy-indie-bowls"].products %}
    {{ custom_products }},{{ product.handle }}
  {% endfor %}
{% endcapture %}

{% assign custom_products = custom_products | split: ',' %}

{% for product in custom_products %}
  {{ product}}
{% endfor %}

但是这段代码没有以正确的方式附加产品。我想要像{{collection.products}} 一样的产品。有什么建议吗?

【问题讨论】:

    标签: ruby shopify liquid shopify-template


    【解决方案1】:

    如果我正确阅读了您的伪代码,那么您正在尝试从产品集合构建产品集合。这就引出了一个问题,为什么?既然你已经有了完美的收藏,那就照原样使用吧!

    【讨论】:

    • 嗨@David Lazar,实际上我有不同的系列,我需要从不同系列中挑选出选定的产品并将其用作单个对象。
    • 您可能会发现使用适合您的规则创建集合要容易得多。用代码从多个集合中挑选产品从来都不是一件有趣的事情。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    • 2013-01-18
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    相关资源
    最近更新 更多