Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

Solved

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

aashby13
Shopify Partner
18 5 5

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
18 5 5

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
449 63 101

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
18 5 5

This is an accepted solution.

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