Show out of stock products on the single page, but hide them from the catalog.

Edward

Member
Hello, I am using the davinci theme and this is that I am trying to achieve:

I want to keep all the products as published, even if they are out of stock (this is in order for clients that find those products on google do not get a 404 page, instead the clients should see the product but with the message of out of stock), but in the same time I don't want to show those products in my catalog, so I want to hide the products that are out of stock from the catalog, but still show the single-product page for out of stock items.

I tried to edit the taxonomy-product_cat.php, but the singleProductMin() function or the singleProduc() function don't provide any stock information when on the category page, so if the singleProductMin() function could provide an index for the array where it could say if on stock or not, we could use it to hide the product.

How can I achieve this, any thoughts?
 
Last edited:

Edward

Member
I thought that was what you wanted?



If they are published, they will show up.

I want a workaround, an update to the theme, or an example of code, so I can hide the out of stock products from the catalogue, but still have the possibility to access the single product page directly for out of stock products.
 

Edward

Member
Around 70% of my products are out of stock, they have good Google ranking and get a lot of traffic to the site, so I don't want to show a 404 because the rentionon rate is lower and Google will remove the url.

But in the same time I don't want to have my product listing page invaded with out of stock products since it can be very annoying for customers.

My shop is 2 years old.
 

Direct Webstore

Well-Known Member
The only thing I can think of is to edit the products manually and replace the seller. There's heaps of sellers selling the same thing. The Url will stay the same.

Unless anyone here has a better idea? I'm out ideas.
 

Edward

Member
My shop is 2 years old there are many products that you can't find them anymore. I know it's not possible to achieve what I want with just tweaking some settings inside WordPress.

I am a programmer I will probably try to code it myself inside the theme files.
 

Direct Webstore

Well-Known Member

Edward

Member
Yes but I don't want to edit the plugin, I will only edit the view (the product category file) and put a condition to not show the product if it's out of stock.

Probably make a child theme to be easy to update the theme in the future.

Thanks I will check also the link.
 
Top