WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Automattic\WooCommerce\Admin\API\Reports

Segmenter::merge_segment_totals_results() protected WC 1.0

Merges segmented results for totals response part.

E.g. $r1 = array(

0 => array(
	 'product_id' => 3,
	 'net_amount' => 15,
),

); $r2 = array(

0 => array(
	 'product_id'      => 3,
	 'avg_order_value' => 25,
),

);

$merged = array(

3 => array(
	 'segment_id' => 3,
	 'subtotals'  => array(
		 'net_amount'      => 15,
		 'avg_order_value' => 25,
	 )
),

);

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->merge_segment_totals_results( $segment_dimension, $result1, $result2 );
$segment_dimension(строка) (обязательный)
Name of the segment dimension=key in the result arrays used to match records from result sets.
$result1(массив) (обязательный)
Array 1 of segmented figures.
$result2(массив) (обязательный)
Array 2 of segmented figures.

Код Segmenter::merge_segment_totals_results() WC 5.5.2

<?php
protected function merge_segment_totals_results( $segment_dimension, $result1, $result2 ) {
	$result_segments = array();
	$segment_labels  = $this->get_segment_labels();

	foreach ( $result1 as $segment_data ) {
		$segment_id = $segment_data[ $segment_dimension ];
		if ( ! isset( $segment_labels[ $segment_id ] ) ) {
			continue;
		}

		unset( $segment_data[ $segment_dimension ] );
		$result_segments[ $segment_id ] = array(
			'segment_label' => $segment_labels[ $segment_id ],
			'segment_id'    => $segment_id,
			'subtotals'     => $segment_data,
		);
	}

	foreach ( $result2 as $segment_data ) {
		$segment_id = $segment_data[ $segment_dimension ];
		if ( ! isset( $segment_labels[ $segment_id ] ) ) {
			continue;
		}

		unset( $segment_data[ $segment_dimension ] );
		if ( ! isset( $result_segments[ $segment_id ] ) ) {
			$result_segments[ $segment_id ] = array(
				'segment_label' => $segment_labels[ $segment_id ],
				'segment_id'    => $segment_id,
				'subtotals'     => array(),
			);
		}
		$result_segments[ $segment_id ]['subtotals'] = array_merge( $result_segments[ $segment_id ]['subtotals'], $segment_data );
	}
	return $result_segments;
}