WC_API_XML_Handler::format_sales_report_data()publicWC 2.1

Adjust the sales report array format to change totals keyed with the sales date to become an attribute for the totals element instead

Метод класса: WC_API_XML_Handler{}

Хуков нет.

Возвращает

Массив.

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

$WC_API_XML_Handler = new WC_API_XML_Handler();
$WC_API_XML_Handler->format_sales_report_data( $data );
$data(массив) (обязательный)
-

Список изменений

С версии 2.1 Введена.

Код WC_API_XML_Handler::format_sales_report_data() WC 8.7.0

public function format_sales_report_data( $data ) {

	if ( ! empty( $data['totals'] ) ) {

		foreach ( $data['totals'] as $date => $totals ) {

			unset( $data['totals'][ $date ] );

			$data['totals'][] = array_merge( array( '@attributes' => array( 'date' => $date ) ), $totals );
		}
	}

	return $data;
}