# Show Stock Status in Shop Listings

> Displays "In stock", "Only 3 left" or "Out of stock" under each product's price on the shop and category pages.

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

## Code

```php
add_action( 'woocommerce_after_shop_loop_item_title', function () {
    global $product;

    if ( ! $product instanceof WC_Product || $product->is_type( array( 'variable', 'grouped', 'external' ) ) ) {
        return;
    }

    echo wp_kses_post( wc_get_stock_html( $product ) );
}, 15 );
```

## Notes

Uses the same availability text as the product page.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Stock Status in Shop Listings" 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/
