Segmenter::get_segment_selections_product_level()protectedWC 1.0

Returns column => query mapping to be used for product-related product-level segmenting query (e.g. products sold, revenue from product X when segmenting by category).

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

Хуков нет.


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


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

Код Segmenter::get_segment_selections_product_level() WC 8.7.0

protected function get_segment_selections_product_level( $products_table ) {
	$columns_mapping = array(
		'num_items_sold' => "SUM($products_table.product_qty) as num_items_sold",
		'total_sales'    => "SUM($products_table.product_gross_revenue) AS total_sales",
		'coupons'        => 'SUM( coupon_lookup_left_join.discount_amount ) AS coupons',
		'coupons_count'  => 'COUNT( DISTINCT( coupon_lookup_left_join.coupon_id ) ) AS coupons_count',
		'refunds'        => "SUM( CASE WHEN $products_table.product_gross_revenue < 0 THEN $products_table.product_gross_revenue ELSE 0 END ) AS refunds",
		'taxes'          => "SUM($products_table.tax_amount) AS taxes",
		'shipping'       => "SUM($products_table.shipping_amount) AS shipping",
		'net_revenue'    => "SUM($products_table.product_net_revenue) AS net_revenue",

	return $columns_mapping;