# "Pre-Order" Badge for Backorder Products

> Labels products that are out of stock but allow backorders with a "Pre-order" badge in the shop and on product pages, so buyers know shipping will be later.

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

## Code

```php
$wpide_backorder_badge = 'Pre-order'; // Badge text.

$wpide_backorder_badge_html = function () use ( $wpide_backorder_badge ) {
    global $product;

    if ( $product instanceof WC_Product && $product->is_on_backorder() ) {
        printf( '<span class="wpide-backorder-badge">%s</span>', esc_html( $wpide_backorder_badge ) );
    }
};

add_action( 'woocommerce_before_shop_loop_item_title', $wpide_backorder_badge_html, 9 );
add_action( 'woocommerce_before_single_product_summary', $wpide_backorder_badge_html, 9 );

add_action( 'wp_head', function () {
    if ( is_woocommerce() ) {
        echo '<style>.woocommerce ul.products li.product,.woocommerce div.product{position:relative}.wpide-backorder-badge{position:absolute;bottom:.5em;left:.5em;z-index:9;padding:.25em .6em;border-radius:3px;background:#6d28d9;color:#fff;font-size:.8em;font-weight:600}</style>';
    }
} );
```

## Notes

Shows on products whose stock status is "On backorder"; change the text to "Backorder" or "Ships later" if you prefer.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Pre-Order" Badge for Backorder Products" 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/
