Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have variant metafield that I'm trying to show on product page next to the variant option. Problem is that it currently shows all variant metafields on all variant options. I don't know how to only show the correct metafield on the correct variant.
Here's my code.
{%- if product.type == 'Cyklar' -%}
{% for variant in product.variants %}
<div class="storlekstext">Passar längd: {{ variant.metafields.custom.langd.value.first }} - {{ variant.metafields.custom.langd.value.last }} cm</div>
{% endfor %}
{%- endif -%}
Hey @jw8 ,
Seems you have json type metafield because custom metafield named as variant.metafields.custom.langd but your metafield name is variant.metafields.custom.langd.value.first
It will be best you could share full structure of your metafield or metafield screenshot, so that we could provide you working solution.
Shopify and our financial partners regularly review and update verification requiremen...
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