We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: Get metafields value in to .js files

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
11207 226 2321

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 '{'