Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
WooPayments::get_supported_country_codes
Get the list of supported country codes for WooPayments.
Method of the class: WooPayments{}
No Hooks.
Returns
Array|null. The list of supported countries as ISO 3166-1 alpha-2 country codes. The country codes are normalized in uppercase. If the list cannot be retrieved, null is returned.
Usage
// private - for code of main (parent) class only $result = $this->get_supported_country_codes(): ?array;
WooPayments::get_supported_country_codes() WooPayments::get supported country codes code WC 10.9.4
private function get_supported_country_codes(): ?array {
try {
if ( $this->proxy->call_function( 'class_exists', 'WC_Payments_Utils' ) &&
$this->proxy->call_function( 'is_callable', 'WC_Payments_Utils::supported_countries' ) ) {
$supported_country_codes = $this->proxy->call_static( 'WC_Payments_Utils', 'supported_countries' );
if ( is_array( $supported_country_codes ) ) {
return array_unique( array_map( 'strtoupper', array_keys( $supported_country_codes ) ) );
}
}
} catch ( Throwable $e ) {
// This is not a critical error, so we just ignore it.
// Log so we can investigate.
SafeGlobalFunctionProxy::wc_get_logger()->error(
'Failed to get the WooPayments supported country codes list: ' . $e->getMessage(),
array(
'source' => 'settings-payments',
)
);
}
return null;
}