How to replace “Out of stock” by “sold” in Woocommerce ?

In this tutorial we’ll learn how to replace ‘out of stock’ product message as sold. When a product’s inventory value reaches at zero the woocommerce will display an ‘out of stock’ message.

Here you can see what it will look like when a product will be out of stock.


Now we need to replace it with the text ‘sold’. To do so, add the following lines of code at the end of your theme’s functions.php file.

add_filter('woocommerce_get_availability', 'availability_filter_func');


function availability_filter_func($availability)


                $availability['availability'] = str_ireplace('Out of stock', 'Sold', $availability['availability']);

                return $availability;



You can access functions.php file here:


About the author

We provide WordPress & WooCommerce Support, Maintenance and Development Services.

Leave a Reply