WC_REST_Shipping_Zones_Controller_Base::get_zone()protectedWC 1.0

Retrieve a Shipping Zone by it's ID.

Method of the class: WC_REST_Shipping_Zones_Controller_Base{}

No Hooks.

Return

WC_Shipping_Zone|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_zone( $zone_id );
$zone_id(int) (required)
Shipping Zone ID.

WC_REST_Shipping_Zones_Controller_Base::get_zone() code WC 8.7.0

protected function get_zone( $zone_id ) {
	$zone = WC_Shipping_Zones::get_zone_by( 'zone_id', $zone_id );

	if ( false === $zone ) {
		return new WP_Error( 'woocommerce_rest_shipping_zone_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	return $zone;
}