Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes
CustomerHistory::get_customer_history
Get the order history for the customer (data matches Customers report).
Method of the class: CustomerHistory{}
No Hooks.
Returns
Array|null
. Order count, total spend, and average spend per order.
Usage
// private - for code of main (parent) class only $result = $this->get_customer_history( $customer_report_id ): ?array;
- $customer_report_id(int) (required)
- The reports customer ID (not necessarily User ID).
CustomerHistory::get_customer_history() CustomerHistory::get customer history code WC 9.9.3
private function get_customer_history( $customer_report_id ): ?array { $args = array( 'customers' => array( $customer_report_id ), // If unset, these params have default values that affect the results. 'order_after' => null, 'order_before' => null, ); $customers_query = new CustomersQuery( $args ); $customer_data = $customers_query->get_data(); return $customer_data->data[0] ?? null; }