Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZoneMethod
Controller::validate_zone
Validate that a shipping zone exists.
Method of the class: Controller{}
No Hooks.
Returns
WC_Shipping_Zone|WP_Error. Zone object or error.
Usage
// protected - for code of main (parent) or child class $result = $this->validate_zone( $zone_id );
- $zone_id(int) (required)
- Zone ID.
Controller::validate_zone() Controller::validate zone code WC 10.4.3
protected function validate_zone( $zone_id ) {
$zone = WC_Shipping_Zones::get_zone( $zone_id );
if ( ! $zone || ( 0 !== $zone->get_id() && ! $zone->get_zone_name() ) ) {
return $this->get_route_error_by_code( self::INVALID_ZONE_ID );
}
return $zone;
}