WooCommerce Change Out Of Stock Text

WooCommerce customised out of stock text

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

If you’ve enabled stock management on our store, customers will see the stock status on the single product page. If a product does not have availability, they’ll see a red sad face and the text “Out of stock”. This quick guide shows you how you can customise this text to show something perhaps a little more fun or tailored towards your business language. Simply edit the text as necessary from the code to transform the in stock text.

				
					/**
 * Snippet Name:	WooCommerce Change Out Of Stock Text
 * Snippet Author:	ecommercehints.com
 */

add_filter( 'woocommerce_get_availability', 'ecommercehints_change_out_of_stock_text', 10, 2);
function ecommercehints_change_out_of_stock_text( $availability, $product ) {
    
    if (!$product->is_in_stock() ) {
        $availability['availability'] = __('Uh On...none left!', 'woocommerce'); // Customised text
    }
    return $availability;
}
				
			

Snippet Benefits

  • Customise the “Out of stock” stock status text to be in-line with your business’ language.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers