How can I address multiple value fields in liquid for metaobjects?

How can I address multiple value fields in liquid for metaobjects?

Kushagra0602
Shopify Partner
16 1 0

Hi guys, I'm facing a problem, please let me know if you've any solution for this. I've created a metaobject with the two values : one is list of files and second list of single line text, and attached it in a product metafield. now when I want to address those values in liquid as currently I'm easily able to address fields with single value but when it comes to multiple values(list of values) it's creating a problem. It's printing nothing when I'm addressing the multiple values field. {% assign prdata = product.metafields.custom.colourvariants.value %} {% assign prdataImg = product.metafields.custom.colourvariants.value.img %} <img src="{{ prdata.secimg | image_url }}" width="30" height="30"> {{ prdataImg }} {{ prdata.secimg }} here is the reference code, in the above code prdataImg contains list of files which is not printing anything and below you can see {{ prdata.secimg }} is a single value field and its visible {{ prdata }} is returning MetaObjectDrop I tried to take ChatGPT help, it also didn't worked out.

Kushagra Dubey
Replies 3 (3)

azamgill
Shopify Partner
325 47 76

Hey @Kushagra0602 

Please try this.

{% assign prdata = product.metafields.custom.colourvariants.value %}

{% for item in prdata %}
  <img src="{{ item.img | image_url }}" width="30" height="30">
  {{ item.text }}
{% endfor %}
Azam Gill
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- Encourage me ❤️

Come and visit us at Wbify
Kushagra0602
Shopify Partner
16 1 0

Didn't work, .img is a list of images and that's where I'm stuck, it's working prefectly with the single value. I tried to loop it also.

Kushagra Dubey
azamgill
Shopify Partner
325 47 76

Sorry to know that it not worked, 

{% assign prdata = product.metafields.custom.colourvariants.value | json %}
{% for item in prdata %}
  <img src="{{ item.img | image_url }}" width="30" height="30">
  {{ item.text }}
{% endfor %}

In this tried JSON

Azam Gill
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- Encourage me ❤️

Come and visit us at Wbify