Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats
Segmenter::segment_selections_orders
Returns column => query mapping to be used for order-level segmenting query (e.g. discount amount when segmented by coupons).
Метод класса: Segmenter{}
Хуков нет.
Возвращает
Массив. Column => SELECT query mapping.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->segment_selections_orders( $coupons_lookup_table, $overrides );
- $coupons_lookup_table(строка) (обязательный)
- Name of SQL table containing the order-level info.
- $overrides(массив)
- Array of overrides for default column calculations.
По умолчанию:array()
Код Segmenter::segment_selections_orders() Segmenter::segment selections orders WC 11.0.1
protected function segment_selections_orders( $coupons_lookup_table, $overrides = array() ) {
$columns_mapping = array(
'amount' => "SUM($coupons_lookup_table.discount_amount) as amount",
'coupons_count' => "COUNT(DISTINCT $coupons_lookup_table.coupon_id) as coupons_count",
'orders_count' => "COUNT(DISTINCT $coupons_lookup_table.order_id) as orders_count",
);
if ( $overrides ) {
$columns_mapping = array_merge( $columns_mapping, $overrides );
}
return $columns_mapping;
}