WC_REST_Data_Countries_Controller::prepare_item_for_response()publicWC 3.5.0

Prepare the data object for response.

Method of the class: WC_REST_Data_Countries_Controller{}

Return

WP_REST_Response. $response Response data.

Usage

$WC_REST_Data_Countries_Controller = new WC_REST_Data_Countries_Controller();
$WC_REST_Data_Countries_Controller->prepare_item_for_response( $item, $request );
$item(object) (required)
Data object.
$request(WP_REST_Request) (required)
Request object.

Changelog

Since 3.5.0 Introduced.

WC_REST_Data_Countries_Controller::prepare_item_for_response() code WC 8.7.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 );
}