Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

No api to add multiple items to cart #171

Open
umxr opened this issue Oct 20, 2021 · 3 comments
Open

No api to add multiple items to cart #171

umxr opened this issue Oct 20, 2021 · 3 comments

Comments

@umxr
Copy link

umxr commented Oct 20, 2021

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.

@kyrylo-soulandwolf
Copy link

This functionality is still missing in 2023!

@jonathanmoore
Copy link

@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);
});

@kyrylo-soulandwolf
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants