Automattic\WooCommerce\Admin\API\Reports

DataStore::get_customer_subquery()protectedWC 1.0

Returns customer subquery to be used in WHERE SQL query, based on query arguments from the user.

Method of the class: DataStore{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_customer_subquery( $query_args );
$query_args(array) (required)
Parameters supplied by the user.

DataStore::get_customer_subquery() code WC 8.7.0

protected function get_customer_subquery( $query_args ) {
	global $wpdb;

	$customer_filter = '';
	if ( isset( $query_args['customer_type'] ) ) {
		if ( 'new' === strtolower( $query_args['customer_type'] ) ) {
			$customer_filter = " {$wpdb->prefix}wc_order_stats.returning_customer = 0";
		} elseif ( 'returning' === strtolower( $query_args['customer_type'] ) ) {
			$customer_filter = " {$wpdb->prefix}wc_order_stats.returning_customer = 1";
		}
	}

	return $customer_filter;
}