Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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 '{'
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025