Liquid, JavaScript, themes, sales channels
Hi guys!
I need to add a product to the 'cart' when I click a button in the checkout page, is that possible?
I've tried adding via AJAX -> cart.js but it's not working.
*PS: the store is Shopify Plus
Hello @will-silveira,
Using cart.js is the way to go. Don't forget to reload the page once is done in order to see the changes.
fetch('/cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ quantity: 1, id: free_variant_id })
})
.then(response => response.json())
.then(response => {
window.location.reload();
})
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024