Skip to main content
Login Join
Snippet · PHP

Change WooCommerce “Out of Stock” Text

Shared by Amit Dholiya · September 2, 2026 · @woocommerce_get_availability

9 views
Back to Snippets

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

  1. Open your theme’s functions.php file.
  2. Add the code below.
  3. Save the file.
  4. 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
);
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments