Localize Price
Convert prices from the native currency to the currently selected currency.
This method uses the currently selected country and currency rules.
Input priceDetails object
Example
| Field Name | Type | Optional | Description |
|---|
Price | number | No | The single price of a product, to be converted. |
ProductClassCoefficient | number | Yes | The product class coefficient to be used in this price conversion. Use null if the product does not have a product class. |
Quantity | number | No | The quantity of the product to be converted. If no value is provided, a default value of 1 is used. |
IsRoundingSkipped | boolean | Yes | If the field is true, the converted price will not be rounded. Do not provide this field if rounding is required. |
Due to rounding rules, the individual product price must be used for the price parameter, not the line item subtotal.
Returned localizedPrice object
| Field Name | Type | Description |
|---|
ConvertedPrice | number | The converted price’s value. |
SymboledPrice | string | The converted price, formatted for the selected currency |
CurrencySymbol | string | The currently selected currency symbol. |
De-localize Converted Price
Convert the customer’s local currency back to the original currency.
This method uses the rules from the current country and currency in the calculation.
Example
Refer to LocalizePrice method to view the structure of the priceDetails and delocalizedPrice objects. The delocalizedPrice object is structured the same as the localizedPrice object.
Format an already converted price, using the currently selected currency.
Input convertedPriceDetails object
| Field Name | Type | Description |
|---|
ConvertedPrice | number | The converted price, to be formatted using the selected currency. |
Returned formattedPrice object
| Field Name | Type | Description |
|---|
SymboledPrice | string | The converted price, formatted for the selected currency. |
CurrencySymbol | string | The currently selected currency symbol. |
Is Operated by Global-e
Check if the currently selected shipping destination country is a Global-e-operated country.
Example
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. If you have a headless Shopify site, use the ShopifyCheckoutId instead of the CartToken.
Example
Update Cart
Receive a notification when the cart needs to be updated on the client side, using this latest cartData that is passed in.
Example
The following events trigger this method:
- 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
cartData
cartDatais a JSON object that matches a specific schema.
Example
productsList
productsList is an array of product objects, detailed below:
| Field Name | Type | Description |
|---|
Name | string | The name of the discount. |
OriginalDiscountValue | number | The value of the discount, in your native currency.This value is converted to the customer’s selected currency |
ProductCartItemId | string | The “CartItemId of the product this discount is for. |
Troubleshooting failed code
If you attempted to use a GEM external method and the code failed, this could be because the GEM 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 that you listen for the GlobalE_Loaded event before executing the code. To do this, set the below function on the window object and the code will be executed when the GEM solution loads.
Example