Get metafield for chosen variant

New Member
6 0 0

So I added one metafield for every variant of an example product with different integer values assigned to them.

I want to display these values depending on the variant the user has currently chosen on the product page. How do I do that?

At the moment this is what I do:

{{ variant.metafields.test.something }}

This gets the correct variable. The problem is that the variable doesn't change when the user selects a different variant of the product. How can I make this interactive?

Thanks a lot! 

0 Likes
Highlighted
Shopify Expert
704 0 65

Try variant.selected.metafields... https://help.shopify.com/en/themes/liquid/objects/variant#variant-selected

I'm a million different people
0 Likes
New Member
6 0 0

Doesnt work.

0 Likes
Shopify Expert
704 0 65

Bummer. Does your URL have a Variant parameter / does that change?

I'm a million different people
0 Likes
New Member
6 0 0

Yes, the &variant=XXX parameter changes.

0 Likes