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.

woocommerce

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:

woocommerce

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

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