# Orders and Total Spent Columns in the Users List

> Adds "Orders" and "Total spent" columns to Users > All Users, so you can spot your best customers and accounts that never ordered.

- Type: PHP
- Runs: Admin only
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, users, customers, columns
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-users-orders-columns/

## Code

```php
add_filter( 'manage_users_columns', function ( $columns ) {
    $columns['wpide_orders'] = 'Orders';
    $columns['wpide_spent']  = 'Total spent';

    return $columns;
} );

add_filter( 'manage_users_custom_column', function ( $value, $column, $user_id ) {
    if ( 'wpide_orders' === $column ) {
        $count = wc_get_customer_order_count( $user_id );

        return $count ? sprintf( '<a href="%1$s">%2$d</a>', esc_url( admin_url( 'admin.php?page=wc-orders&_customer_user=' . $user_id ) ), $count ) : '0';
    }

    if ( 'wpide_spent' === $column ) {
        return wp_kses_post( wc_price( wc_get_customer_total_spent( $user_id ) ) );
    }

    return $value;
}, 10, 3 );
```

## Notes

Uses WooCommerce's cached customer totals, which update after each order.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Orders and Total Spent Columns in the Users List" 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/
