Noptin_WooCommerce::get_total_spent( $customer_id_or_email )
Contents
Source Source
File: includes/integrations/class-noptin-woocommerce.php
public function get_total_spent( $customer_id_or_email ) { if ( empty( $customer_id_or_email ) ) { return 0; } if ( is_numeric( $customer_id_or_email ) ) { return (float) wc_get_customer_total_spent( $customer_id_or_email ); } // Fetch all customer orders. $orders = wc_get_orders( array( 'limit' => -1, 'billing_email' => $customer_id_or_email, 'status' => wc_get_is_paid_statuses(), ) ); $total = 0; // Get the sum of order totals. foreach( $orders as $order ) { $total += $order->get_total(); } return $total; }
Expand full source code Collapse full source code View on GitHub