I had a customer with a WooCommerce store who had products that were “coming soon”, but the only option for out of stock was an ugly “Out of Stock” marker above the product image.
I was surprised there were no plugins that seemed to work for this change. The one I found had a bunch of reviews saying it no longer worked. Then, I found this code for the functions.php file, but it only changes the text on the single product page and not on the catalog page.
add_filter('woocommerce_get_availability', 'availability_filter_func'); function availability_filter_func($availability) { $availability['availability'] = str_ireplace('Out of stock', 'Coming Soon!', $availability['availability']); return $availability; }
You can see here that I changed my ‘Out of stock’ text to ‘Coming Soon!’ but you can change coming soon to whatever you want.
This code allowed me to put a notice on the shop page:
(sorry for not having live text here, but WordPress kept executing the code.)
**As with any code change to your functions.php file, I recommend you have a backup of the original file and access to the file via ftp or file manager, just in case the site crashes. There is always a chance that placing PHP code incorrectly can take down your site.
Update: I have found this as another solution:

As used on my customer’s site: ebikesbyrevolve.com
PHP Snippet 1: Show “Sold Out” on Shop and Archive Pages If You Have no Existing “Out Of Stock” Badge – WooCommerce
/**
* @snippet Display "Sold Out" on Loop Pages - WooCommerce
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 4.6
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_display_sold_out_loop_woocommerce' );
function bbloomer_display_sold_out_loop_woocommerce() {
global $product;
if ( ! $product->is_in_stock() ) {
echo 'Sold Out';
}
}
And a bit of CSS:
/* CSS */ .soldout { padding: 3px 8px; text-align: center; background: #222; color: white; font-weight: bold; position: absolute; top: 6px; right: 6px; font-size: 12px; }
See the full article here: https://www.businessbloomer.com/woocommerce-show-sold-archiveproduct-page/
Stone says
Hi,
After insterting the code into my site using the code snippet pluggin my site stopped working.
Error message: “”websitename.net is currently unable to handle this request””
I have disabled and removed the codes but still my site wont work.
Your kind assistance and suggestions would be appreciated.
Regards
Laura Hartwig says
I’m sorry this happened to you. I”m not sure which plugin you were using. Perhaps there is caching on your site which needs to be cleared? Otherwise I would recommend that you contact the plugin developer. Good luck!
Arlene Soto says
The Archive display code isn’t working. Getting a fatal error on line 5 and had to add } to line 6.
Help please 🙂 I don’t know much code.
Laura Hartwig says
My apologies. The code box cut off too early. I have corrected it now and hopefully it will work better for you.
Cecilia says
Thank you for this information. The first coding went well but the archive display code isn’t working. There’s an error showing up on line 5 – something because of the &. Can you help me?
Regards
Laura Hartwig says
My apologies. It looks like the visual editor changed some of my code. I have updated it now. Please try again and let me know.
Sean says
the archive code didnt work for me. any ideas what I’m doing wrong?
Thakn you so much!!!
Laura Hartwig says
Hi Sean, Can you share the page where you’re trying to get it to work?
Kim says
The archive code isn’t working for me (the first one did though, thank you). I’m adding it to my WP site via snippets and I get this error: https://d.pr/free/i/CxhLlt
Here is the code I copied and pasted, here from your site, https://d.pr/free/i/OtcTLA
Any help would be greatly appreciated.
Laura Hartwig says
Hi, I think the code might have gone a little awry with wordpress trying to change it to text. I’ve updated it now. Please see if that works better for you.
Kim says
That was it! Thank you so much. That was the finishing touch I needed. xoxo
Laura Hartwig says
I’m glad it worked for you – and sorry the code got messed up before!
kammy says
today this works
add_filter( ‘woocommerce_get_availability’, ‘wcs_custom_get_availability’, 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
// Change In Stock Text
if ( $_product->is_in_stock() ) {
$availability[‘availability’] = __(‘Available!’, ‘woocommerce’);
}
// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability[‘availability’] = __(‘Sold Out’, ‘woocommerce’);
}
return $availability;
}
you must add to child theme functions.php
Carolina says
The code helped me a lot! It’s working just fine. Thank you so much!
Laura Hartwig says
I’m glad it helped. Thanks for letting me know!
Patrick says
I’m currently getting this error. even though i removed the code.
Screenshot>> https://prnt.sc/z5tc6f
Laura Hartwig says
Sounds like you didn’t remove all the code. Hopefully you had a backup of the file like I suggested. The site looks fine now, so hopefully you worked it out?
Greenware says
I tried to my site too, but it doesn’t work. I got this error – syntax error, unexpected ‘!’, expecting ‘)’
Laura Hartwig says
I’m sorry this happened to you. Did you copy and paste the code exactly? And did it say which line has the error? It looks like you missed a parentheses at the end somewhere.
Ivan says
The code for shop page is broken because wrong HTML. Consider fixing it.
Laura Hartwig says
Sorry. I ended up having to make it into a picture because WordPress kept executing the code.
Rafael Molina says
for us no techies we wish there was an easy plugin for this, because that OUT OF STOCK is hideous