# Order Count and Total Spent on the Account Dashboard

> Shows customers how many orders they have placed and how much they have spent in total, a nice touch for loyalty or VIP programmes.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, my-account, loyalty, customers
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-account-lifetime-stats/

## Code

```php
add_action( 'woocommerce_account_dashboard', function () {
    $user_id = get_current_user_id();
    $count   = wc_get_customer_order_count( $user_id );

    if ( ! $count ) {
        return;
    }

    printf(
        '<p class="wpide-account-stats">%s</p>',
        wp_kses_post( sprintf( 'You have placed <strong>%1$d</strong> order(s) with us, totalling <strong>%2$s</strong>. Thank you!', $count, wc_price( wc_get_customer_total_spent( $user_id ) ) ) )
    );
}, 5 );
```

## Notes

Uses WooCommerce's cached customer totals, so it adds no heavy queries.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Order Count and Total Spent on the Account Dashboard" 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/
