Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
So I have a variant metafield called "material".
But whenever I try to put it in a page, it doesn't show up!
And when I try to force it to show up, it says it's invalid.
How do I fix this?
Hi @jmpt16,
Because you create Metafield Variants, so you just call it out with code, you can't import it at Customize.
You need to add "for" variant for it. Refer
{%- for variant in product.variants -%}
{{variant.metafields.my_fields.material }}
{%- endfor -%}
Hope it is clear to you.
Still doesn't work that way, Shopify says it's invalid.
Hi @jmpt16,
Can you send me the screenshot where you add the code. I will check it.
Because it needs to be added at main-product.liquid file.
Hope it helps!
Oh, I didn't know I had to add it to main-product.liquid.
Well, now it shows up, but it shows every variant's metafield value for every dropdown.
(yes, those are the values i gave to the products. Heck, there should be more but I didn't bother filling them all out just yet)
Here's a code screenshot:
How do I get only this variant's metafield value and only in the first dropdown?
(P.S: I'm gonna need to add another variant metafield for the 3rd dropdown as well)
Hi @jmpt16,
Please change code:
{{ product.selected_or_first_available_variant.metafields.my_fields.material }}
Hope it helps!
Works perfect, thanks man!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025