What's your biggest current challenge? Have your say in Community Polls along the right column.

Remove a item from the cart based on product ID or Tag

Remove a item from the cart based on product ID or Tag

GraphicPass
Shopify Partner
6 0 1

I was wondering if it's possible to remove an item from the cart if its added? We are using a bundling app that adds individual items to the cart as well as the "main bundle" I wanted to keep the individual items in the cart but the remove the main bundle product. Is there a script to remove an item based on the product id?

Replies 2 (2)

Visely-Team
Shopify Partner
1843 210 488

You can POST into /cart/change.js with quantity 0 and the id of the variant you want to delete from the cart. More info here - https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#change-cart

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
DreamyDeveloper
Tourist
4 0 1

I also just wanted to post a link since it took me quite a while to find out there is a simple library that already has done all this.

Go into this link and you can download a library from them with some guidelines on how to do a simple removal of product based on other factors. (such as product ID)

https://cartjs.org/