How can I automatically remove sold out items from the shopping bag?

how can Automatically remove something that is sold out from the shopping bag.

I try to add code in cart-template.liquid but its not working ,anyone have this type of solution?

{% for variant in product.variants %}
{% if variant.available %}
{% endif %}
{% endfor %}

Hello @Surbhi106 !

The way to automatically hide out of stock products is through automatic collections which you may have already set up.

Automatic collections work based on conditions, so if you’re tracking stock for your products you need to make sure to add a condition to each collection that says inventory stock is greater than 0:

![23-22-6585-97710|807x296](upload://wtTE1G4FxTl8pZiolDzvJzZ9tkb.png)

That way, any products that go below 1 in inventory will be automatically removed from the collections. Have you tried this already?

Also, please do tell me a little bit more about your store and products, I will see if there is anything else I can be of help with!