Shopify Liquid - 相关产品作为metafield的特定手柄

时间:2018-01-10 09:11:09

标签: shopify liquid

我正在尝试使用带有逗号分隔句柄列表的Shopify元字段(即:handle1,handle2)来调用特定的相关产品。这些相关产品显示在各个产品页面上。我的问题是:我无法弄清楚如何从数组中获取产品进行迭代和显示。

我正在使用Boundless主题,因此我尝试以与收集页面相同的方式调用/显示产品。这可能是我问题的一部分。

由于某种原因,我当前的代码会调用页面上的实际产品而不是相关产品。

这是我目前的代码:

{% if product.metafields.c_f['Shown With'] %}
 {% assign shownwith = product.metafields.c_f['Shown With'] | split: ',' %}

 {% capture shownwith_items %}
  {% for product in shownwith %}
   {% include 'product-grid-width' with product_image_type: section.settings.product_image_type, product_image_size: section.settings.product_image_size %}
   {% include 'product-grid-item' with product_image_spacing: section.settings.product_image_spacing, vendor_enable: section.settings.vendor_enable %}
  {% endfor %}
 {% endcapture %}

{% endif %}

1 个答案:

答案 0 :(得分:0)

{%if product.metafields.c_f ['With With']%}  {%assign shownwith = product.metafields.c_f ['Show with'] |拆分:','%}

{%capture shownwith_items%}   {% relPro 显示为%}

{%assign product = all_products [srelPro]%}

{%include'product-grid-width'with product_image_type:section.settings.product_image_type,product_image_size:section.settings.product_image_size%}    {%include'product-grid-item'with product_image_spacing:section.settings.product_image_spacing,vendor_enable:section.settings.vendor_enable%}   {%endfor%}  {%endcapture%}

{{shownwith_items}} {%endif%}