How to Change The Default Out of Stock Notification in WooCommerce

Changing the Out of stock label for sold out products on WooCommerce is quite easy. All you need to do is add a few lines of PHP code into the functions.php file on the theme folder.

You don’t need to worry about the code because we have already written it for you. All you need to do is copy the code from below and paste it into the functions.php file. You will also need to replace the placeholder text in the code with your custom message.

So, let’s get started.

  1. Open WordPress Theme Editor

    Log into the WordPress admin dashboard and open Theme Editor where you can make changes in the files inside your theme folder. To open Theme Editor, go to Appearance and then Choose Theme Editor.

    1. Open functions.php file

      In the Theme Editor screen, you can see a text editor at the center and a list of files in your theme at the right side.

      Scroll down through the list of Theme Files and click on Theme Functions (functions.php) to open functions.php on the text editor.

      1. Copy the code snippet

        add_filter('woocommerce_get_availability_text', 'themeprefix_change_soldout', 10, 2 );

        * Change Sold Out Text to Something Else
        function themeprefix_change_soldout ( $text, $product) {
        if ( !$product->is_in_stock() ) {
        $text = '<div class="">Sold out.</div>';
        return $text;

        1. Add the code to function.php file

          In the text editor, scroll down to the bottom of the functions.php file and paste the code copies form above at the end of the document.

          1. Edit the code snippet

            The above code will replace the Out of stock with Sold out.

            If you want to add a custom message instead of Sold out, you can replace the Sold out text in the code with anything you want.

            After changing the text, click on the Save changes button at the bottom, and now you have successfully changed Out of stock text with your custom text on WooCommerce message.


            The default “Out of stock” label for sold out products is quite plain. Replacing it with a more assuring message will help you to reduce the customer disappointment. Fortunately, it’s not that difficult to change it. All you need to do is add the few lines of PHP code given above to the functions.php file on your theme and replace the placeholder string in the code.