Global Liquid variable not working in Java file

Cilian
New Member
1 0 0

Hi,

I'am currently building a upsell section in the ajax cart (Brooklyn Theme).

I need the variant.id of a product in my js file but have no idea how to do it. I tried everything I know.

 

//That's the code that works in every other file (exept the java file):
{%- assign product = all_products[settings.upsell_product] -%}

{{ product.variants[0].id }}

//The funny thing is that the following code works, even in the js file
{{ settings.upsell_headline }} 

 

 

The code inside my settings_schema.json:

 

      {
        "type": "header",
        "content": {
          "de": "Cart Upsell"
        }
      },
      {
        "type": "text",
        "id": "upsell_headline",
        "label": {
          "de": "Headline"
        }
      },
      {
        "type": "product",
        "id": "upsell_product",
        "label": {
          "de": "Upsell Product"
        }
      }
    ]
  },

 

 

 

 

0 Likes