To hide out of stock products from your customers, you can use automated collections as follows :
From your Shopify store Dashboard Go to Products > Collections.
Select a collection that you want to hide out-of-stock products from.
3. Change the automated collection conditions, and add the following conditions:
For ''Products must match'', select all conditions.
For ''Inventory stock'', select is greater than and enter 1.
This procedure makes sure that your automated collections don't contain any products that are out of stock, and that those products won't appear to your customers. Any out-of-stock products will appear in your collections again after you receive inventory.
Note: After applying the steps above, the products will be only hidden from the selected collection, you will need to repeat the same procedure for all the other collections you have in your store.