WC_Shipping_Zones::get_continent_code_for_location
Get the continent code for a country or state location.
Method of the class: WC_Shipping_Zones{}
No Hooks.
Returns
string. Continent code, or an empty string.
Usage
$result = WC_Shipping_Zones::get_continent_code_for_location( $location );
- $location(object) (required)
- Location.
Changelog
| Since 11.1.0 | Introduced. |
WC_Shipping_Zones::get_continent_code_for_location() WC Shipping Zones::get continent code for location code WC 11.1.2
private static function get_continent_code_for_location( $location ) {
$type = $location->type ?? '';
$code = $location->code ?? '';
if ( 'continent' === $type ) {
return $code;
}
$country_code = 'state' === $type ? self::get_country_code_from_state_code( $code ) : $code;
return WC()->countries->get_continent_code_for_country( $country_code );
}