How can I extract metafields value into a .js file?

How can I extract metafields value into a .js file?

ejkej87
Shopify Partner
11 0 1

How to extract the metafields value to a .js file and assign it to a variable to use it later in the function and check the true false value?

Replies 3 (3)

Jason
Shopify Partner
11196 226 2287

What have you tried so far? Even creating a global var in within the dom would get you to a solution so just want to make sure I'm not repeating things you've already attempted.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
ejkej87
Shopify Partner
11 0 1

I would like to set 2 values ​​in metafields true false and assign their value to a variable in js. And then if false do something other than true. Just can't get metafields value in .js file

ejkej87
Shopify Partner
11 0 1

I try do something like this:
let foo = {{ variant.metafields.custom.only_onetime_buy_option | json }};
console.log( foo )
but shows me Unexpected token '{'