WC_REST_Report_Orders_Totals_Controller::prepare_item_for_response()
Prepare a report object for serialization.
Метод класса: WC_REST_Report_Orders_Totals_Controller{}
Хуки из метода
Возвращает
WP_REST_Response
. $response Response data.
Использование
$WC_REST_Report_Orders_Totals_Controller = new WC_REST_Report_Orders_Totals_Controller(); $WC_REST_Report_Orders_Totals_Controller->prepare_item_for_response( $report, $request );
- $report(stdClass) (обязательный)
- Report data.
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_REST_Report_Orders_Totals_Controller::prepare_item_for_response() WC REST Report Orders Totals Controller::prepare item for response WC 9.2.3
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-report-orders-totals-controller.php
public function prepare_item_for_response( $report, $request ) { $data = array( 'slug' => $report->slug, 'name' => $report->name, 'total' => $report->total, ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); // Wrap the data in a response object. $response = rest_ensure_response( $data ); /** * Filter a report returned from the API. * * Allows modification of the report data right before it is returned. * * @param WP_REST_Response $response The response object. * @param object $report The original report object. * @param WP_REST_Request $request Request used to generate the response. */ return apply_filters( 'woocommerce_rest_prepare_report_orders_count', $response, $report, $request ); }