Under “Products” and “Inventory” I have checked the following setting:
“Hide out of stock items from the catalog”
Now all sold out products are hidden in the archive/category view. So far so good.
The problem is that the hidden (out of stock) products are counted per page. So if there are 3 products that are sold out on the first page, only the ones in stock are showing (6).
It also seems that these “hidden” products still are searchable as well, and visible through the different widgets.
Any ideas how to fix this? I mean to REALLY hide products that are out of stock. Or do I need to manuallly remove them?
You can try adding this to your theme’s functions.php file:
I modified the code from this URL: http://www.wptaskforce.com/how-to-exclude-one-or-more-category-in-woocommerce-shop-page/
Saved here again just in case that site goes offline: (this code excludes certain product categories)
Note to self: Always read the changelog from developer.
Found the answer here: http://develop.woothemes.com/woocommerce/2014/02/solving-common-issues-after-updating-to-woocommerce-2-1/#category-counts-incorrect
Update: Also remember that it is not enough to change stock quantity to 0. You must also set “Stock status” to “Out of stock”. If not the product will be counted in the shop, even if there are no products in stock.
I found easier way, if anybody is still looking for hiding out of stock products in woocommerce, follow these easy steps without editing html !
that will only work if you are using the official woocommerce shortcodes , but if you creating a page with visual composer and using customized plugins or 3rd party plugins or shortcodes , the first step is to for the query that run from the loop then you modify it to something like this
the most important part that you have to be sure of is
Steps to Hide Out of Stock Products
I know that this question was asked long time ago but the solution of the problem is now different, so I post this for people who had the same problem as I did. Tested on WooCommerce 5.3.0
SOLUTION:
First of all make sure that checkbox “Hide products that are out of stock” in Woocomerce > Settings is unchecked than add this PHP code to your child-theme functions.php file:
It works well in my store, which is integrated with a wholesaler, where inventory levels are updated every hour and there are thousands of products.
You can place PHP snippet at the bottom of your child theme functions.php file.