get_calling_code_for_country

This commit is contained in:
Mike Jolley 2019-02-08 11:09:42 +00:00
parent b46a9e5941
commit 8a1a1d3e73
1 changed files with 18 additions and 0 deletions

View File

@ -90,6 +90,24 @@ class WC_Countries {
return '';
}
/**
* Get calling code for a country code.
*
* @since 3.6.0
* @param string $cc Country code.
* @return string
*/
public function get_calling_code_for_country( $cc ) {
$codes = wp_cache_get( 'calling-codes', 'countries' );
if ( ! $codes ) {
$codes = json_decode( file_get_contents( WC()->plugin_path() . '/i18n/phone.json' ), true ); // Data from http://country.io/phone.json.
wp_cache_set( 'calling-codes', $codes, 'countries' );
}
return isset( $codes[ $cc ] ) ? $codes[ $cc ] : '';
}
/**
* Get continents that the store ships to.
*