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?
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!