Solved

Looping through metafield that is a list of variants acts like there is only 1 item

aashby13
Shopify Partner
12 4 0

I created a bundler app the utilizes variant metafields. App works fine, no issues there. But I do want to display some info about the bundled items on the product page. When I loop thru the metafield list, it acts as if there is only 1 item in the list. The list count even comes back as 1. If I loop through the quantities metafield, a list of integers, it works as expected. 

 

You can see there are 7 items in each list.

Screen Shot 2024-04-05 at 6.03.00 PM.png

 

 

 

{% for ref in product.variants[0].metafields.custom.component_reference.value %}
<p>{{ ref.product.title }}</p>
{% endfor %}

 

 

Above results in 1 title being displayed.

 

 

{% for quantity in product.variants[0].metafields.custom.component_quantities.value %}
  <p>{{ quantity }}</p>
{% endfor %}

 

 

Above results in 7 quantity values being displayed.

Accepted Solution (1)

aashby13
Shopify Partner
12 4 0

This is an accepted solution.

Oop! Nevermind. Majority of products in the metafield list are still dafts. Thats why.

View solution in original post

Replies 2 (2)

deepaksharma
Shopify Partner
448 63 93

Hi there @aashby13 

 

Is this something similar you need?

 

deepaksharma_0-1712380542753.png

Here these are the list of product I have selected in the metafield

deepaksharma_1-1712380610871.png

 

If interested do let me know

Deepak Sharma || Shopify Developer || Helping eCommerce Stores
- Was my reply helpful? Accept it as solution
- Was your question answered? Mark it as an Accepted Solution.
-CHAT ON WHATSAPP | BUY ME A COFFEE | MAIL ME: ds2305187@gmail.com

aashby13
Shopify Partner
12 4 0

This is an accepted solution.

Oop! Nevermind. Majority of products in the metafield list are still dafts. Thats why.