When your products are out-of-stock and you want to hide them in your collections, please refer to this article. You can do this manually on the Collections page of your Shopify admin to do it for you.
Before you can hide sold-out products from your collections, you need to enable inventory tracking in your Shopify admin. Inventory tracking automatically keeps track of the inventory level of each product that you carry.
Step 1: Enable inventory tracking for your products.
From your Shopify admin, go to Products.
Click the name of the product that you want to track.
If the product has variants, then click the variant that you want to track.
In the Inventory section, check Track quantity.
In the Quantity section, enter the quantity information for each location.
Click Save.
Step 2: Change the automated collection conditions.
You need to change the conditions for each of your collections, and add the following conditions:
For Products must match, select all conditions.
For Inventory stock, select is greater than and enter 0.
Note: This solution for hiding sold-out products will not work if you set Products must match to any condition.