# Custom Stock Availability Messages

> Replaces the standard "Out of stock" and "Available on backorder" labels on product pages with your own wording.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, stock, product-page
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-custom-availability-text/

## Code

```php
add_filter( 'woocommerce_get_availability_text', function ( $text, $product ) {
    // Your wording for each stock status. Empty keeps the default.
    $messages = array(
        'outofstock'  => 'Sold out, back soon',
        'onbackorder' => 'Ships in 2-3 weeks',
    );

    if ( ! $product instanceof WC_Product ) {
        return $text;
    }

    $status = $product->get_stock_status();

    return ! empty( $messages[ $status ] ) ? $messages[ $status ] : $text;
}, 10, 2 );
```

## Notes

Leave a message empty to keep the WooCommerce default for that status.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Custom Stock Availability Messages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
