【问题标题】:Shopify Liquid - Related products as specific handles from a metafieldShopify Liquid - 相关产品作为元字段中的特定句柄
【发布时间】:2018-06-19 09:50:59
【问题描述】:

我正在尝试使用带有逗号分隔句柄列表的 Shopify 元字段(即:句柄 1、句柄 2)来调用特定的相关产品。这些相关产品显示在单独的产品页面上。我的问题是:我不知道如何从数组中获取产品进行迭代和显示。

我正在使用 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 %}

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

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

    {% 捕获显示与_items %} {% for relPro 显示为 %}

    {% 分配产品 = 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 %} {% 结束捕获 %}

    {{ 显示的项目}} {% endif %}

    【讨论】:

      猜你喜欢
      • 2016-05-16
      • 1970-01-01
      • 2012-10-27
      • 2023-02-08
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      相关资源
      最近更新 更多