I am attempting to extract product data into a javascript variable, so that I can work with the whole object in my javascript, however I can’t seem to figure out the correct syntax, I have tried the following:
{% assign upsellProduct1 = all_products['laundry-bag'] %}
And different variations of it, but I can’t seem to get it to work. If I try to assign a specific property, it works, but otherwise it just gives me ProductDrop.
So these are the variants that I have tried:
const product = {'{{upsellProduct1}}'}; // doesnt work -> ProductDrop
const product = '{{{upsellProduct1}}}'; // doesnt work -> ProductDrop
const product = { ...{{upsellProduct1}} }; // doesnt work -> ProductDrop
const product = '{{upsellProduct1.handle}}'; // specific property works
What is the correct way to assign the whole product to a javascript variable?