WC_Shipping_Zones::location_covers_location
Check whether one location covers another location.
Method of the class: WC_Shipping_Zones{}
No Hooks.
Returns
bool. Whether the possible broader location covers the location.
Usage
$result = WC_Shipping_Zones::location_covers_location( $possible_broader_location, $location );
- $possible_broader_location(object) (required)
- Possible broader location.
- $location(object) (required)
- Location to check.
Changelog
| Since 11.1.0 | Introduced. |
WC_Shipping_Zones::location_covers_location() WC Shipping Zones::location covers location code WC 11.1.2
private static function location_covers_location( $possible_broader_location, $location ) {
$broader_type = $possible_broader_location->type ?? '';
$broader_code = $possible_broader_location->code ?? '';
$type = $location->type ?? '';
$code = $location->code ?? '';
if ( $broader_type === $type && $broader_code === $code ) {
return true;
}
if ( 'continent' === $broader_type ) {
return self::get_continent_code_for_location( $location ) === $broader_code;
}
if ( 'country' === $broader_type ) {
return 'state' === $type && self::get_country_code_from_state_code( $code ) === $broader_code;
}
return false;
}