Add customer lifetime spent to the user info column in WooCommerce

add_filter( 'manage_users_columns', 'lifetime_spent_user_column' );
  
function lifetime_spent_user_column( $columns ) {
    $columns['user_spent'] = 'Lifetime spend';
    return $columns;
}
  
add_filter( 'manage_users_custom_column', 'lifetime_spent_user_column_content', 10, 3 );
  
function lifetime_spent_user_column_content( $content, $column, $user_id ) {
    
    if ( 'user_spent' === $column ) {
   $customer = new WC_Customer( $user_id );
        $content = $customer->get_total_spent(); 
    }
    
    return wc_price( $content, array( 'currency' => $currency ) );
}

You can extend the states by adding additional states to the $states array.

This code can be added following the instructions here:

How to add custom code to your WooCommerce/WordPress site the right way

Have any feedback? Be sure to let me know here: Contact me

4 thoughts on “Add customer lifetime spent to the user info column in WooCommerce

    1. Good question! Let me look into this and update back here as soon as I can. I can’t make any promises but should be before end of the weekend.

Share your thoughts

Your email address will not be published. Required fields are marked *