How To Change WooCommerce Out Of Stock Message

Blog Inbox
2 min readJul 23, 2022

--

Illustration by Icons 8 from Ouch!

WooCommerce is one of the most used eCommerce platforms in the world and for a good reason. Unfortunately there is no premade setting to change your availability message regarding products. Thankfully it is possible to change the “In Stock” and “Out Of Stock” messages with a small piece of code, which you can find from below.

/**
* @snippet Out of stock and in stock message changes
* @author https://bloginbox.com
* @testedwith WooCommerce 6.7
*/
add_filter( 'woocommerce_get_availability', 'bloginbox_custom_get_availability', 1, 2);
function bloginbox_custom_get_availability( $availability, $_product ) {
// Changes the "In Stock" message
if ( $_product->is_in_stock() ) {
$availability['availability'] = __('MY IN STOCK MESSAGE', 'woocommerce');
}
// Changes the "Out Of Stock" message
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('MY OUT OF STOCK MESSAGE', 'woocommerce');
}
return $availability;
}

To use the code you need to add it to your functions.php and save. You can easily change the “in stock” or “out of stock” by changing the “MY IN STOCK MESSAGE” and “MY OUT OF STOCK MESSAGE” to your likings.

Note — If you do not have stock management in use in your store you won’t be able to see the messages.

Here’s how the changes looks in action. First we have the normal “In Stock” and with a small change we have turned the “In Stock” to “Available Now!” with an emoji after the text.

Disclosure: In compliance with the FTC guidelines, please assume the following links: Any/all of the links on this post are affiliate links from which we receive a small compensation from sales of certain items.

Prices are exactly the same for you if your purchase is through an affiliate link or a non-affiliate link. You will not pay more by clicking through to the link.

--

--