0
votes

I am trying to use a Shopify metafield with a comma separated list of handles (ie: handle1,handle2) to call specific related products. These related products are displayed on individual product pages. My problem is: I cannot figure out how to get the products from the array to iterate and display.

I am using the Boundless theme, so I am trying to call/display the products in the same manner as a collection page. This may be part of my problem.

My current code calls the actual product on the page instead of the related products for some reason.

Here is my current code:

{% 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

1 Answers

0
votes

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

{% capture shownwith_items %} {% for relPro in shownwith %}

{% 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 %}