Skip to main content
The ExternalMethodsComponent exposes public methods merchants can call to interact with the Bespoke Global-e Module, Global-e’s front-end framework — to convert and format prices, control user localization, display UI elements, and retrieve shipping information. All methods are called via:

Pricing & Conversion

Localize Price

Convert prices from the native currency to the currently selected currency. This method uses the currently selected country and currency rules.

Signature

Input — priceDetails object

Due to rounding rules, the individual product price must be used for the Price parameter, not the line item subtotal.

Example

Returned — localizedPrice object

Format Converted Price

Format an already-converted price, using the currently selected currency. This is useful when you have already converted a price and need to display it with proper formatting.

Signature

Input — convertedPriceDetails object

Example

Returned — formattedPrice object

Get Product Class Coefficient

Retrieve the price coefficient rate for a specific product class. Product class coefficients are used for category-specific pricing adjustments configured in the Global-e merchant settings.

Signature

Parameters

Returned

A coefficient of 0 means no coefficient is applied. The method returns 0 both when the product class is not found and when it is configured with a coefficient of 0.

Example

Localization Settings

Set User Localization

Sets the user’s localization preferences (country and currency) by updating the GlobalE_Data cookie on the merchant’s domain, then refreshes the page so that Global-e Module scripts take effect with the new settings.

Signature

Input — userLocalization object

Example

Invoking this method refreshes the page.
If CountryCode is not provided, the current user’s country is retained. The method updates the localization cookie (GlobalE_Data) and triggers a full page reload.

Get User Localization

Retrieves the user’s current localization settings (country and currency).

Signature

Parameters

Example

Returned object

Change Localize Settings

Changes the user’s localization settings (country and currency) without displaying any UI, then triggers a callback upon completion.

Signature

Parameters

Example

Difference from Set User Localization

UI Components

Show Shipping Switcher

Programmatically displays the Shipping Switcher popup, allowing merchants to trigger the country/currency selection UI on demand. Useful for custom implementations where the merchant controls when and how the switcher appears.

Signature

Parameters

Example

This method requires that the Shipping Switcher component is configured and enabled in the merchant’s Global-e Module configuration. If it is not enabled, this method has no effect.

Show Welcome Popup

Programmatically displays the Welcome Popup, which typically shows localization information and lets users confirm or change their country/currency preferences.

Signature

Parameters

Example

Behavior

When forceWelcome is true, the method resets the welcome popup cookie, allowing it to appear again. Requires the Welcome Popup component to be enabled in the merchant’s configuration.

Shipping

Get Free Shipping Threshold

Retrieve the free shipping threshold information for a specific country and currency combination — the minimum order amount required to qualify for free shipping. A GeoIP variant uses the user’s current location instead of an explicit country/currency.

Signature

Input — parameters object

*Not required for GetFreeShippingThresholdByGeoIP, which takes only a callback.

Returned object

CartData object

Example

Example Response (success)

Example Response (no free shipping)

Is Operated by Global-e

Check whether the currently selected shipping destination country is a Global-e-operated country.

Signature

Example

Cart & Checkout

Get Checkout URL

Get the checkout URL that you want to direct customers to. urlParams is a JSON object with a single CartToken string parameter.

Signature

Example

Update Cart

Call this method to pass the latest cart data to the Global-e Module.

Signature

Call this method when:
  • A product is added to the cart
  • A product is removed from the cart
  • The quantity of a product is changed
  • The cart is shown to the user

Example

cartData object

cartData is a JSON object that matches a specific schema.
discountsList

Event Dependencies

Several methods wait for specific Global-e Module events before executing, ensuring the necessary configuration data is loaded first:

Troubleshooting failed code

If you attempted to use a Global-e Module external method and the code failed, this could be because the Global-e Module has not loaded yet. In this situation, you can use an ExternalEventsComponent. With the ExternalEventsComponent you can set a function on the window object, and Global-e’s code executes that function when a certain event is triggered. We recommend listening for the GlobalE_Loaded event before executing your code: