This is an accepted solution.
You need to modify the code in the theme. What is your shop url, I can do it if you want.
You can use this app Stockyphi -Stockyphi - Out of Stock Manager
The app has following features
Hiding the out of stock items may not always be the best solution. All of the product pages have SEO power for your store, and it is developing for a long time. When you hide a sold-out product, you lose index and links to it; this means you lose all the product's SEO power. And when you unhide it, it starts all over. So, if you will re-stock the item, you should keep out of stock products on your site - just don't put them in front of your customers.
Our app, Push Down & Hide Out of Stock, move out of stock products to the bottom of the collection. If you will not re-stock a product, you can hide it also. If an item is back in stock, it is also published automatically. Combining these features is the best and easiest way to improve conversions by managing out-of-stock products.
If you are determined to hide all out-of-stock products, of course, you can also use only hiding&unhiding feature.
You can find more details on our app page. It has an easy setup, and all processes automatic.
We have a free plan, and if it is suitable for you, you can use it for free! If you have any questions, please don't hesitate to reach out to us at email@example.com