WC_Countries::get_continent_code_for_country
Get continent code for a country code.
Method of the class: WC_Countries{}
No Hooks.
Returns
String.
Usage
$WC_Countries = new WC_Countries(); $WC_Countries->get_continent_code_for_country( $cc );
- $cc(string) (required)
- Country code.
Changelog
| Since 2.6.0 | Introduced. |
WC_Countries::get_continent_code_for_country() WC Countries::get continent code for country code WC 10.6.2
public function get_continent_code_for_country( $cc ) {
$cc = trim( strtoupper( $cc ) );
$continents = $this->get_continents();
$continents_and_ccs = wp_list_pluck( $continents, 'countries' );
foreach ( $continents_and_ccs as $continent_code => $countries ) {
if ( false !== array_search( $cc, $countries, true ) ) {
return $continent_code;
}
}
return '';
}