If you want to replace the default “Out of stock” message with a more customer-friendly message, you can do it using a WooCommerce filter.
Steps
- Open your theme’s
functions.phpfile. - Add the code below.
- Save the file.
- Open an out-of-stock product.
Done — the default stock message will be replaced with your custom text.
function change_out_of_stock_text( $availability, $product ) {
if ( ! $product->is_in_stock() ) {
$availability['availability'] = 'Currently unavailable';
}
return $availability;
}
add_filter(
'woocommerce_get_availability',
'change_out_of_stock_text',
10,
2
);