I can’t get this to work after hours and hours of research. I hope someone can help me.
In woocommerce, the out of stock message is only displayed on the single product page and NOT on the catalog page. This means someone first has to click on the product to find out it’s sold out. Bummer. It’s important for us to show the out of stock product, since we’re selling unique products. The “Out of stock” notice has to be visible directly under the product image.
W’re dying for a solution 🙂
Kind regards,
Roos
In 2017, this snippet will work:
The easiest way will be with css:
Each product on the catalog will have a < li > tag. If the product has stock it will have this class “instock” if it does not have stock it will have this class “outofstock”
So you can create this css:
remember to replace the image.png url with yours.
Found this snippet here. Worked perfectly on my site.
I know it’s been quite a while but I just want to do the same and noticed that there are two classes, on the li-element in the loop.
vs
If it’s just the markup you want to change, maybe just do the CSS and don’t hook into woocommerce just for the message.
@yuvalsab, nice one 😉
This is working on 2020
=======================
This works for me, added in theme functions.php file: