WC_REST_Shipping_Zones_V2_Controller::get_items()publicWC 1.0

Get all Shipping Zones.

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

Хуков нет.

Возвращает

WP_REST_Response.

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

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

Код WC_REST_Shipping_Zones_V2_Controller::get_items() WC 9.3.3

public function get_items( $request ) {
	$rest_of_the_world = WC_Shipping_Zones::get_zone_by( 'zone_id', 0 );

	$zones = WC_Shipping_Zones::get_zones();
	array_unshift( $zones, $rest_of_the_world->get_data() );
	$data = array();

	foreach ( $zones as $zone_obj ) {
		$zone   = $this->prepare_item_for_response( $zone_obj, $request );
		$zone   = $this->prepare_response_for_collection( $zone );
		$data[] = $zone;
	}

	return rest_ensure_response( $data );
}