How To Change WooCommerce Out Of Stock Message

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 it. 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 liking.

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 look 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.

WooCommerce In Stock
Customized WooCommerce In Stock that now says Available Now!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *