WC_REST_Shipping_Zone_Locations_V2_Controller::get_items()publicWC 1.0

Get all Shipping Zone Locations.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error.

Использование

$WC_REST_Shipping_Zone_Locations_V2_Controller = new WC_REST_Shipping_Zone_Locations_V2_Controller();
$WC_REST_Shipping_Zone_Locations_V2_Controller->get_items( $request );
$request(WP_REST_Request) (обязательный)
Request data.

Код WC_REST_Shipping_Zone_Locations_V2_Controller::get_items() WC 8.7.0

public function get_items( $request ) {
	$zone = $this->get_zone( (int) $request['id'] );

	if ( is_wp_error( $zone ) ) {
		return $zone;
	}

	$locations = $zone->get_zone_locations();
	$data      = array();

	foreach ( $locations as $location_obj ) {
		$location = $this->prepare_item_for_response( $location_obj, $request );
		$location = $this->prepare_response_for_collection( $location );
		$data[]   = $location;
	}

	return rest_ensure_response( $data );
}