Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

Segmenter::get_segment_selections_order_level()protectedWC 1.0

Returns column => query mapping to be used for order-related product-level segmenting query (e.g. avg items per order when segmented by category).

Метод класса: Segmenter{}

Хуков нет.

Возвращает

Массив. Column => SELECT query mapping.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_segment_selections_order_level( $unique_orders_table );
$unique_orders_table(строка) (обязательный)
Name of SQL table containing the order-level segmenting info.

Код Segmenter::get_segment_selections_order_level() WC 8.9.0

protected function get_segment_selections_order_level( $unique_orders_table ) {
	$columns_mapping = array(
		'orders_count'        => "COUNT($unique_orders_table.order_id) AS orders_count",
		'avg_items_per_order' => "AVG($unique_orders_table.num_items_sold) AS avg_items_per_order",
		'avg_order_value'     => "SUM($unique_orders_table.net_total) / COUNT($unique_orders_table.order_id) AS avg_order_value",
		'total_customers'     => "COUNT( DISTINCT( $unique_orders_table.customer_id ) ) AS total_customers",
	);

	return $columns_mapping;
}