1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
<?php
if (!function_exists('asa2_i18n_get_user_country_iso_code')) {
/**
* This method retrieves the user’s ISO country code.
*
* Example:
* ```php
* $isoCode = asa2_i18n_get_user_country_iso_code();
* // $isoCode contains the user's ISO country code, like "US", "UK", "DE" ...
* ```
*
* @since 1.8.0
* @package i18n
*
* @param bool $storeMatch Optional. Set to true to get an ISO country code which is the best match for an Amazon store related to the user’s origin. Default is true.
* @return null|string ISO country code or null on error
*/
function asa2_i18n_get_user_country_iso_code($storeMatch = true) {
if (class_exists('Asa2_Module_Premium_GeoIp')) {
if ($storeMatch == true) {
return Asa2_Module_Premium_GeoIp::getStoreSafeUserCountryIsoCode();
} else {
return Asa2_Module_Premium_GeoIp::getUserCountryIsoCode();
}
}
}
}
if (!function_exists('asa2_i18n_get_store_safe_user_country_iso_code')) {
/**
* This method retrieves an ISO country code which is the best match for an Amazon store related to the user’s origin.
* @deprecated use asa2_i18n_get_user_country_iso_code instead
* @package i18n
* @ignore can be deleted in future
* @return string ISO country code or null on error
*/
function asa2_i18n_get_store_safe_user_country_iso_code() {
if (class_exists('Asa2_Module_Premium_GeoIp')) {
return Asa2_Module_Premium_GeoIp::getStoreSafeUserCountryIsoCode();
}
}
}
if (!function_exists('asa2_i18n_get_user_data')) {
/**
* This function retrieves detailed information about the user’s origin country.
*
* Example:
* ```php
* $userOrigin = asa2_i18n_get_user_data();
* echo '<pre>';
* print_r($userOrigin);
* // output:
* Array
(
[continent] => Array
(
[code] => EU
[geoname_id] => 6255148
[names] => Array
(
[de] => Europa
[en] => Europe
[es] => Europa
[fr] => Europe
[ja] => ヨーロッパ
[pt-BR] => Europa
[ru] => Европа
[zh-CN] => 欧洲
)
)
[country] => Array
(
[geoname_id] => 2921044
[iso_code] => DE
[names] => Array
(
[de] => Deutschland
[en] => Germany
[es] => Alemania
[fr] => Allemagne
[ja] => ドイツ連邦共和国
[pt-BR] => Alemanha
[ru] => Германия
[zh-CN] => 德国
)
)
[registered_country] => Array
(
[geoname_id] => 2921044
[iso_code] => DE
[names] => Array
(
[de] => Deutschland
[en] => Germany
[es] => Alemania
[fr] => Allemagne
[ja] => ドイツ連邦共和国
[pt-BR] => Alemanha
[ru] => Германия
[zh-CN] => 德国
)
)
)
* ```
* @package i18n
* @return array|null
*/
function asa2_i18n_get_user_data() {
if (class_exists('Asa2_Module_Premium_GeoIp')) {
return Asa2_Module_Premium_GeoIp::getUserData();
}
}
}