WC_REST_Shipping_Zones_V2_Controller::prepare_item_for_response()
Prepare the Shipping Zone for the REST response.
Method of the class: WC_REST_Shipping_Zones_V2_Controller{}
No Hooks.
Return
WP_REST_Response
. $response
Usage
$WC_REST_Shipping_Zones_V2_Controller = new WC_REST_Shipping_Zones_V2_Controller(); $WC_REST_Shipping_Zones_V2_Controller->prepare_item_for_response( $item, $request );
- $item(array) (required)
- Shipping Zone.
- $request(WP_REST_Request) (required)
- Request object.
WC_REST_Shipping_Zones_V2_Controller::prepare_item_for_response() WC REST Shipping Zones V2 Controller::prepare item for response code WC 9.2.3
public function prepare_item_for_response( $item, $request ) { $data = array( 'id' => (int) $item['id'], 'name' => $item['zone_name'], 'order' => (int) $item['zone_order'], ); $context = empty( $request['context'] ) ? 'view' : $request['context']; $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 ); $response->add_links( $this->prepare_links( $data['id'] ) ); return $response; }