WC_REST_Data_Countries_Controller::prepare_item_for_response()publicWC 3.5.0

Prepare the data object for response.

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

Хуки из метода


WP_REST_Response. $response Response data.


$WC_REST_Data_Countries_Controller = new WC_REST_Data_Countries_Controller();
$WC_REST_Data_Countries_Controller->prepare_item_for_response( $item, $request );
$item(объект) (обязательный)
Data object.
$request(WP_REST_Request) (обязательный)
Request object.

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

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

Код WC_REST_Data_Countries_Controller::prepare_item_for_response() WC 8.9.0

public function prepare_item_for_response( $item, $request ) {
	$data     = $this->add_additional_fields_to_object( $item, $request );
	$data     = $this->filter_response_by_context( $data, 'view' );
	$response = rest_ensure_response( $data );

	$response->add_links( $this->prepare_links( $item ) );

	 * Filter the states list for a country returned from the API.
	 * Allows modification of the location data right before it is returned.
	 * @param WP_REST_Response $response The response object.
	 * @param array            $data     The original country's states list.
	 * @param WP_REST_Request  $request  Request used to generate the response.
	return apply_filters( 'woocommerce_rest_prepare_data_country', $response, $item, $request );