Remove all sold out items from a cart

Shopify Partner
44 0 2

Hey everyone,

I was wondering if I could remove a sold out item from cart. I am using  {% if item.variant.available %} to prevent the item from rendering, but its not actually updating the cart to reflect the price change. Any way to do this.

Thanks for your time,

Cheers

0 Likes
Shopify Expert
460 0 74

You would be better off not allowing the product to be added to the cart if it's sold out. But if it happens that a product gets sold out while someone is in the process of trying to buy it, you'd have to use some javascript to actually remove it from their cart. Or you could just output a message on the cart line item that says it is no longer available, and then when they checkout they will have the opportunity to remove it when the Inventory Issues message comes up.

0 Likes
Shopify Partner
44 0 2

Thanks for the reply Gina. I did this using a bit of liquid and a JSON post call to change the quantity to zero.

Thanks again,

Cheers

0 Likes
New Member
2 0 0
Can you provide scripts to do the check that you did?
0 Likes