Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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
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?
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 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
I try do something like this:
let foo = {{ variant.metafields.custom.only_onetime_buy_option | json }};
console.log( foo )
but shows me Unexpected token '{'