# "Sold X Times" Note on Product Pages

> Shows how many times a product has been bought below its price, as social proof once it passes a minimum number of sales.

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

## Code

```php
add_action( 'woocommerce_single_product_summary', function () {
    $min_sales = 10; // Hide the note below this many sales.

    global $product;

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

    $sales = (int) $product->get_total_sales();

    if ( $sales < $min_sales ) {
        return;
    }

    echo '<p class="wpide-units-sold" style="margin:.5em 0;font-size:.95em;">' . esc_html( sprintf( 'Bought %s times', number_format_i18n( $sales ) ) ) . '</p>';
}, 11 );
```

## Notes

Set $min_sales so new products do not show a low number.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Sold X Times" Note on Product Pages" 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/
