Shopify themes, liquid, logos, and UX
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 %}
Solved! Go to the solution
This is an accepted solution.
It seems that I have figured it out.
This is an accepted solution.
{% for product_metafield in product.metafields.custom.product_swatch.value %}
{{ product_metafield.product.value.url }}
{{ product_metafield.title }}
{{ product_metafield.color }}
{% endfor %}
Here is the code to loop through all the metaobject values in the product
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?
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 guest
This is an accepted solution.
It seems that I have figured it out.
This is an accepted solution.
{% for product_metafield in product.metafields.custom.product_swatch.value %}
{{ product_metafield.product.value.url }}
{{ product_metafield.title }}
{{ product_metafield.color }}
{% endfor %}
Here is the code to loop through all the metaobject values in the product
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025