wc_get_customer_total_spent

Get total spent by customer.

Description

(string) wc_get_customer_total_spent( (int) $user_id ); 

Returns (string)

Parameters (1)

0. $user_id (int)
The user id.

Usage

  1. if ( !function_exists( 'wc_get_customer_total_spent' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-user-functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_customer_total_spent($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-user-functions.php  
  1. function wc_get_customer_total_spent( $user_id ) { 
  2. $customer = new WC_Customer( $user_id ); 
  3. return $customer->get_total_spent();