In some cases, even insignificant changes on your WordPress site cause lots of mess while trying to edit them in some simple way. Let’s talk about default Woocommerce “out of stock” string and find out how to edit mentioned string without any additional functionality.
Simple as ABC, just copy/paste the code below to your functions.php and save changes:
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; }
First of all, make sure inventory status is set to “out of stock” within inner dashboard, then refresh site in browser with ctrl+shift+R to observe changes.
As you can see, there is no need to use sided Woocommerce out of stock plugin, just couple actions and Woocommerce out of stock message was edited almost immediately.