theme-scripts
theme-scripts copied to clipboard
No api to add multiple items to cart
There doesn't seem to be an API to add multiple items to the cart, is this something that is planning on being added. I know this is supported by the /cart/add route. the dev docs validate this. https://shopify.dev/api/ajax/reference/cart#post-cart-add-js. I'll be more than happy to pick this up.
This functionality is still missing in 2023!
@kyrylo-soulandwolf On Shopify you've been able to add multiple items at once since the very beginning of the Cart API. Items is an array, so you can always send multiple items with the variant ID to add many at once.
let formData = {
'items': [
{
'id': 36110175633573,
'quantity': 2
},
{
'id': 36110175633581,
'quantity': 1
},
]
};
fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
})
.then(response => {
return response.json();
})
.catch((error) => {
console.error('Error:', error);
});
@jonathanmoore so what's the point of theme-cart
package if adding multiple items needs to be done by hand? the problem isn't about Shopify API not supporting it, but having a package that doesn't support all the functionality provided by the API.