2
votes

Checking "Hide out of stock items from the catalog" option hides out-of-stock products everywhere. I want to hide them from the Shop page, but not from individual category archive pages (http://.../product-category/category1/, http://.../product-category/category2/, etc).

Is there a way to do this?

1

1 Answers

2
votes

This is possible by creating a file called content-product.php in yourtheme/woocommerce and copying the contents of the file content-product.php in woocommerce/templates. What you need to change is on line 25.

if ( ! $product || ! $product->is_visible()) 

and add || !$product->is_in_stock() to the if statement. The if statement should look like:

if ( ! $product || ! $product->is_visible() || !$product->is_in_stock() )

Adding || !$product->is_in_stock() will check to see if the product is in stock, if not it won't show it in the loop.