Automattic\WooCommerce\Admin\API\Reports
Segmenter::reformat_intervals_segments()
Update row-level db result for segments in 'intervals' section to the format used for output.
Метод класса: Segmenter{}
Хуков нет.
Возвращает
Массив
. Reformatted array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->reformat_intervals_segments( $segments_db_result, $segment_dimension );
- $segments_db_result(массив) (обязательный)
- Results from the SQL db query for segmenting.
- $segment_dimension(строка) (обязательный)
- Name of column used for grouping the result.
Код Segmenter::reformat_intervals_segments() Segmenter::reformat intervals segments WC 9.3.3
protected function reformat_intervals_segments( $segments_db_result, $segment_dimension ) { $aggregated_segment_result = array(); if ( strpos( $segment_dimension, '.' ) ) { $segment_dimension = substr( strstr( $segment_dimension, '.' ), 1 ); } $segment_labels = $this->get_segment_labels(); foreach ( $segments_db_result as $segment_data ) { $segment_id = $segment_data[ $segment_dimension ]; if ( ! isset( $segment_labels[ $segment_id ] ) ) { continue; } $time_interval = $segment_data['time_interval']; if ( ! isset( $aggregated_segment_result[ $time_interval ] ) ) { $aggregated_segment_result[ $time_interval ] = array(); $aggregated_segment_result[ $time_interval ]['segments'] = array(); } unset( $segment_data['time_interval'] ); unset( $segment_data['datetime_anchor'] ); unset( $segment_data[ $segment_dimension ] ); $segment_datum = array( 'segment_label' => $segment_labels[ $segment_id ], 'segment_id' => $segment_id, 'subtotals' => $segment_data, ); $aggregated_segment_result[ $time_interval ]['segments'][ $segment_id ] = $segment_datum; } return $aggregated_segment_result; }