How to delete line item in cart with a specific property match

KevinKarma
Tourist
3 0 0

Hi all! 

so I have multiple items in the cart that will have the same variant_id but with a difference in property value: for example, items in my cart might look similar to the following:

cart.items = [ {id: 123, quantity: 1, properties: [ {caseId: 1122} ] }, {id: 123, quantity: 1, properties: [ {caseId: 3344} ] } ]



what I'm looking for is to write an ajax call to cart/update.js and remove items with id: 123 and properties with caseID: 3344 but not caseId: 1122 

Replies 3 (3)
jstukey
New Member
2 0 1

Were You able to get the working? I’m about to take a stab at the same exact scenario for a bundle builder that pops the bundle in the cart linking all bundled products via a custom line item property with a unique bundle id. That part is working - yay! Next up is to target the bundle in cart and delete all items with the same bundle id via Ajax. 

KevinKarma
Tourist
3 0 0

Once in the cart, each item will have its own unique id (key) which can be used to remove it from the cart with Ajax call. 

jstukey
New Member
2 0 1

Thank you @KevinKarma! Yes, I worked that out yesterday exactly as you stated using the key.