If you’re running a WooCommerce store, you may want to automatically hide out of stock products to keep your store looking tidy and uncluttered. There are a few different ways you can do this, and which method you choose will depend on your particular needs.
One way to automatically hide out of stock products is to use the built-in setting in WooCommerce. To do this, go to WooCommerce > Settings > Products > Inventory and check the box next to “Hide out of stock items from the catalog”.
This will cause any out of stock products to be hidden from your shop page, category pages, and search results. However, customers will still be able to view these products if they have the direct URL.