getCountryCode()
Gets the current country code.
Signature
const countryCode = window.FairShareSDK.getCountryCode();
Returns
string — The current country code (e.g., "US", "CA", "GB").
How Country is Determined
The country code is automatically determined using the following priority:
- Explicit user setting — Set via
updateLocaleSettings() - IP Geolocation — Automatically detected on first visit
- Company default — Configured in shop settings
- Alphabetical fallback — First available country by ISO code
Example
const countryCode = window.FairShareSDK.getCountryCode(); console.log('Current country:', countryCode); // e.g., "US"
Related
- Settings Overview — How locale detection works
- Country — Country selector component
- updateLocaleSettings — Update locale settings
- getLanguage — Get current language