WC_Countries::country_exists()publicWC 5.1.0

Check if a given code represents a valid ISO 3166-1 alpha-2 code for a country known to us.

Method of the class: WC_Countries{}

No Hooks.

Return

true|false. True if the country is known to us, false otherwise.

Usage

$WC_Countries = new WC_Countries();
$WC_Countries->country_exists( $country_code );
$country_code(string) (required)
The country code to check as a ISO 3166-1 alpha-2 code.

Changelog

Since 5.1.0 Introduced.

WC_Countries::country_exists() code WC 8.7.0

public function country_exists( $country_code ) {
	return isset( $this->get_countries()[ $country_code ] );
}