Automattic\WooCommerce\Admin\API\Reports
DataStore::create_interval_subtotals()
Change structure of intervals to form a correct response.
Also converts local datetimes to GMT and adds them to the intervals.
Метод класса: DataStore{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->create_interval_subtotals( $intervals );
- $intervals(массив) (обязательный) (передается по ссылке — &)
- Time interval, e.g. day, week, month.
Код DataStore::create_interval_subtotals() DataStore::create interval subtotals WC 8.7.0
protected function create_interval_subtotals( &$intervals ) { foreach ( $intervals as $key => $interval ) { $start_gmt = TimeInterval::convert_local_datetime_to_gmt( $interval['date_start'] ); $end_gmt = TimeInterval::convert_local_datetime_to_gmt( $interval['date_end'] ); // Move intervals result to subtotals object. $intervals[ $key ] = array( 'interval' => $interval['time_interval'], 'date_start' => $interval['date_start'], 'date_start_gmt' => $start_gmt->format( TimeInterval::$sql_datetime_format ), 'date_end' => $interval['date_end'], 'date_end_gmt' => $end_gmt->format( TimeInterval::$sql_datetime_format ), ); unset( $interval['interval'] ); unset( $interval['date_start'] ); unset( $interval['date_end'] ); unset( $interval['datetime_anchor'] ); unset( $interval['time_interval'] ); $intervals[ $key ]['subtotals'] = (object) $this->cast_numbers( $interval ); } }