在shopify Liquid 中制作自定义系列-liquid

问题描述

我想根据一些条件场景在 collection.liquid 中创建一个自定义集合,为此我应用了 concatappendjoin,但问题是它返回 {{ 1}} 或 ProductDropProductDropProductDropProductDrop... 而不是产品。以下是代码片段

LazyProductDropCollectionLazyProductDropCollection

我尝试了 {% assign custom_products = '' %} {% for product in collections["paneer-easy-indie-bowls"].products %} {% assign custom_products = custom_products | append: product %} {% endfor %} join 而不是 append 但返回 concat

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 %} 一样的产品。有什么建议吗?

解决方法

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