Segmenter::segment_selections_orders()protectedWC 1.0

Returns column => query mapping to be used for order-level segmenting query (e.g. discount amount when segmented by coupons).

Method of the class: Segmenter{}

No Hooks.


Array. Column => SELECT query mapping.


// protected - for code of main (parent) or child class
$result = $this->segment_selections_orders( $coupons_lookup_table, $overrides );
$coupons_lookup_table(string) (required)
Name of SQL table containing the order-level info.
Array of overrides for default column calculations.
Default: array()

Segmenter::segment_selections_orders() code WC 7.3.0

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;