If you are using WooCommerce for the ecommerce on your WordPress website you may want to update the out of stock text to different custom text like sold or something like that. To do that without a plugin you can then add this code to your functions.php file. We recommend that you backup your WordPress website before you make updates the file on there.
Update out of stock text on WooCommerce
/** * Update WooCommerce out of stock text * * @author WPSnacks.com * @link https://wpsnacks.com/ */ function availability_filter_func($availability) { $availability['availability'] = str_ireplace('Out of stock', 'YOURTEXTHERE', $availability['availability']); return $availability; } add_filter('woocommerce_get_availability', 'availability_filter_func');
You would then replace YOURTEXTHERE with the text you want like sold or something like that. Now if that works for you it would update the out of stock text in WooCommerce on your WordPress website on there.
Leave a Reply