TMS Selector API Documentations

Accessing the API

After initialization, the API is available globally at: window.tms.selectorApi

API Properties

Property

Type

Description

Example Output

language { code: string } The current language code { code: "en" }
region { code: string } The current region code { code: "CA" }
currency { code: string } The current currency code { code: "CAD" }
type string The selector type (see possible values below) "region-language-selector"
visitorGeo { code: string } The visitor’s geo region code (IP-based) { code: "US" }

Selector Type Values


The type property can return one of the following strings:
  • "language-selector"
  • "region-selector"
  • "region-language-selector"
  • "currency-selector"
  • "currency-language-selector"


Example Usage

// Get the current language
const language = window.tms.selectorApi.language;

// Get the current region
const region = window.tms.selectorApi.region;

// Get the current currency
const currency = window.tms.selectorApi.currency;

// Get the selector type
const selectorType = window.tms.selectorApi.type;

// Get the visitor's geo region
const visitorGeo = window.tms.selectorApi.visitorGeo;

Currency Converter API

The currencyConverterApi provides currency conversion data and configuration.
Property
Type
Description
Example Output
currency
Promise<CurrencyConverterApiTypes>
Returns currency conversion settings and exchange rate info
See below

CurrencyConverterApiTypes

Field
Type
Description
Example
isEnabled
boolean
Indicates if currency conversion is active. Conversion applies only to currencies managed by TMS. Currencies displayed directly by Shopify are not affected by TMS.
true
fromCurrency
{ code: string }
The base or origin currency object
{ code: "USD" }
toCurrency
object
The target currency object (see below)
See toCurrency table
rate
string
The current exchange rate used for conversion
"1.34"

toCurrency

Field
Type
Description
Example
code
string
Currency code
"CAD"
symbol
string
Currency symbol
"$"
format
string
Currency format (see Shopify reference)
"amount"
symbolPlacement
string
"before" or "after" – position of symbol relative to amount
"before"
roundingRule
string
Rounding rule applied. Possible values: "round_up", "round_down", "round_nearest", "no" (no rounding)
"round_nearest"
roundingDecimal
string
How the decimal part ends. For example, "99" means if the price was 10.34, it will display as 10.99
"99"

Currency Format Options

The format used in toCurrency corresponds to Shopify's currency formatting options.
See Shopify docs for full details: Shopify Currency Formatting Options

Example Usage

const conversion = await window.tms.currencyConverterApi.currency;

if (conversion.isEnabled) {
console.log("From currency code:", conversion.fromCurrency.code);
const toCur = conversion.toCurrency;
console.log("To currency:", toCur.code, toCur.symbol);
console.log("Format:", toCur.format);
console.log("Symbol placement:", toCur.symbolPlacement);
console.log("Rounding rule:", toCur.roundingRule);
console.log("Rounding decimals:", toCur.roundingDecimal);
console.log("Exchange rate:", conversion.rate);
} else {
console.log("Currency conversion is disabled.");
}

Notes:

  • All properties are read-only.
  • The API is automatically available on the page once initialized.
  • If a value is not recognized or available, a default such as "" is returned.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us