Solved

Render metaobjects that is being used in metafields list

lentreb0902
Shopify Partner
3 1 0

Here is the corrected text:

I have created a metaobject for my color swatch. Here are the fields: color, image, and product. Then, I created product metafields and selected the metaobject that I had created for the swatches. I set the product metafields as a list. However, I have difficulty in rendering the value. I hope there is someone who can help.


{% for product_metafield in product.metafields.custom.product_swatch %}

{% for metaobject in product_metafield.values %}
<div class="custom swatches">
{{ metaobject.field }}
{{ metaobject.value }}
</div>
{% endfor %}
{% endfor %}

Accepted Solution (1)

lentreb0902
Shopify Partner
3 1 0

This is an accepted solution.

It seems that I have figured it out. 

View solution in original post

Replies 4 (4)

Lorena783lopez
Visitor
1 0 1

Your corrected text looks good! It seems like you're using Liquid code within a template to render product metafields for color swatches. The {% for %} loops are correctly structured, iterating over each product metafield and its values. The code snippet should render each metaobject's field and value within the specified div class.

 

Is there anything specific you're still struggling with regarding rendering the values, or is there anything else you need help with?

lentreb0902
Shopify Partner
3 1 0

the problem is, its not displaying. I can't figure it out. It seems that I misunderstood the structure. Its not a list of metafields, but a single product metafields that handles a list of metaobjects. I image.pngguest

lentreb0902
Shopify Partner
3 1 0

This is an accepted solution.

It seems that I have figured it out. 

Ryan_Silva
Shopify Partner
1 0 0

@lentreb0902 Can you please share your solution?