Ajax Card can't use variables

Christopher99
Excursionist
18 0 5

Hello everyone,

i am having troubles using the Ajax Cart Update Function.
When hardcoding the variant_id, everything works but when i pack the variant_id into a variable it "cannot find variant". (Ajax Cart Add is working like this)
The variable does contain the same id.
What did I do wrong ?

<button onclick="addToCart({{ variant.id }})">Add</button>

function addToCart(test) { 
    
    jQuery.post('/cart/update.js', {
      updates: {
        test: 1}
    });	   
  }

 

0 Likes