Automattic\WooCommerce\Admin\API\Reports\PerformanceIndicators
Controller::get_analytics_report_data()
Get analytics report data and endpoints.
Метод класса: Controller{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_analytics_report_data();
Код Controller::get_analytics_report_data() Controller::get analytics report data WC 9.8.2
private function get_analytics_report_data() { $request = new \WP_REST_Request( 'GET', '/wc-analytics/reports' ); $response = rest_do_request( $request ); if ( is_wp_error( $response ) ) { return $response; } if ( 200 !== $response->get_status() ) { return new \WP_Error( 'woocommerce_analytics_performance_indicators_result_failed', __( 'Sorry, fetching performance indicators failed.', 'woocommerce' ) ); } $endpoints = $response->get_data(); foreach ( $endpoints as $endpoint ) { if ( '/stats' === substr( $endpoint['slug'], -6 ) ) { $request = new \WP_REST_Request( 'OPTIONS', $endpoint['path'] ); $response = rest_do_request( $request ); if ( is_wp_error( $response ) ) { return $response; } $data = $response->get_data(); $prefix = substr( $endpoint['slug'], 0, -6 ); if ( empty( $data['schema']['properties']['totals']['properties'] ) ) { continue; } foreach ( $data['schema']['properties']['totals']['properties'] as $property_key => $schema_info ) { if ( empty( $schema_info['indicator'] ) || ! $schema_info['indicator'] ) { continue; } $stat = $prefix . '/' . $property_key; $this->allowed_stats[] = $stat; $stat_label = empty( $schema_info['title'] ) ? $schema_info['description'] : $schema_info['title']; $this->labels[ $stat ] = trim( $stat_label, '.' ); $this->formats[ $stat ] = isset( $schema_info['format'] ) ? $schema_info['format'] : 'number'; } $this->endpoints[ $prefix ] = $endpoint['path']; $this->urls[ $prefix ] = $endpoint['_links']['report'][0]['href']; } } }