WC_Shipping_Zones::zone_covers_zone
Check whether a possible broader zone fully covers another zone.
Method of the class: WC_Shipping_Zones{}
No Hooks.
Returns
bool. Whether the possible broader zone fully covers the zone.
Usage
$result = WC_Shipping_Zones::zone_covers_zone( $possible_broader_zone, $zone );
- $possible_broader_zone(array) (required)
- Possible broader zone.
- $zone(array) (required)
- Zone to check.
Changelog
| Since 11.1.0 | Introduced. |
WC_Shipping_Zones::zone_covers_zone() WC Shipping Zones::zone covers zone code WC 11.1.2
private static function zone_covers_zone( $possible_broader_zone, $zone ) {
if ( self::zone_has_postcode_locations( $possible_broader_zone ) ) {
return false;
}
if (
self::zone_has_unsupported_non_postcode_locations( $possible_broader_zone ) ||
self::zone_has_unsupported_non_postcode_locations( $zone )
) {
return false;
}
$broader_locations = self::get_zone_locations_by_type( $possible_broader_zone, array( 'continent', 'country', 'state' ) );
$zone_locations = self::get_zone_locations_by_type( $zone, array( 'continent', 'country', 'state' ) );
if ( empty( $zone_locations ) ) {
return empty( $broader_locations );
}
if ( empty( $broader_locations ) ) {
return true;
}
foreach ( $zone_locations as $zone_location ) {
$is_location_covered = false;
foreach ( $broader_locations as $broader_location ) {
if ( self::location_covers_location( $broader_location, $zone_location ) ) {
$is_location_covered = true;
break;
}
}
if ( ! $is_location_covered ) {
return false;
}
}
return true;
}