Last updated

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:

  1. Explicit user setting — Set via updateLocaleSettings()
  2. IP Geolocation — Automatically detected on first visit
  3. Company default — Configured in shop settings
  4. Alphabetical fallback — First available country by ISO code

Example

const countryCode = window.FairShareSDK.getCountryCode();
console.log('Current country:', countryCode); // e.g., "US"