WC_REST_Shipping_Zones_Controller_Base::get_zone
Retrieve a Shipping Zone by it's ID.
Method of the class: WC_REST_Shipping_Zones_Controller_Base{}
No Hooks.
Returns
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() WC REST Shipping Zones Controller Base::get zone code WC 10.4.3
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;
}