Happening now! Shopify Community AMA: Building a Marketing Budget with 2H Media | Ask your marketing budget questions now!

How can I access custom meta fields in a JS file?

How can I access custom meta fields in a JS file?

aivarsyo
Shopify Partner
1 0 0

I have created a custom meta field for variants with namespace and key like this custom.variant_images. In the Liquid file, I can access it this way {{variant.metafields.custom.variant_images}}.

 

But now I want to access it from my JS file. I managed to get a JSON output for a product, but under variants, I can't find a line for my custom meta field. How can I access it? Some code example is appreciated.

Reply 1 (1)

Rachid_98
Shopify Partner
12 1 2

Have you been able to have an solution?