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

Method of the class: WC_API_XML_Handler{}

No Hooks.

Return

Array.

Usage

$WC_API_XML_Handler = new WC_API_XML_Handler();
$WC_API_XML_Handler->format_sales_report_data( $data );
$data(array) (required)
-

Changelog

Since 2.1 Introduced.

WC_API_XML_Handler::format_sales_report_data() code 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;
}