Skip to main content

Documentation Portal

Initialization

Global-e initialization is handled in the int_globale/cartridge/scripts/globale/globaleInit.js file, for any storefront call. In the following situations, Global-e will skip the initialization:

  • Global-e is disabled in Site Preferences.

  • The country and currency have not changed since the last call.

  • The client IP address is one of the whitelisted IPs.

Hooks

Each Global‑e extension cartridge has its own hooks.

SiteGenesis

int_globale_sitegenesis/package.json int_globale_sitegenesis/cartridge/scripts/hooks.json

Hook Name

Hook Script

Description

dw.system.request.onRequest

int_globale/cartridge/scripts/hooks/request/OnRequest.js

Performs Main Global‑e Initialization on every storefront request

dw.ocapi.shop.basket.calculate

int_globale_sitegenesis/cartridge/scripts/cart/calculate.js

Performs Cart/Basket prices recalculation (for older SiteGenesis)

dw.order.calculate

int_globale_sitegenesis/cartridge/scripts/cart/calculate.js

Performs Cart/Basket prices recalculation (when it's called from int_globale)

dw.order.createOrderNo

int_globale_sitegenesis/cartridge/scripts/hooks/order.js

Returns SFCC order number to be used during order creation.

dw.ocapi.shop.basket.beforePATCH

int_globale_sitegenesis/cartridge/scripts/hooks/basket.js

The function is called before updating of the basket.

dw.ocapi.shop.basket.coupon.beforePOST

int_globale_sitegenesis/cartridge/scripts/hooks/basket/coupon.js

The function is called before adding a coupon to a basket.

dw.ocapi.shop.basket.coupon.beforeDELETE

int_globale_sitegenesis/cartridge/scripts/hooks/basket/coupon.js

The function is called before removing a coupon from a basket.

dw.ocapi.shop.order.beforePOST

int_globale_sitegenesis/cartridge/scripts/hooks/order.js

The function is called before an order is created for the basket.

dw.ocapi.shop.order.afterPOST

int_globale_sitegenesis/cartridge/scripts/hooks/order.js

The function is called after an order was created from the basket.

SFRA

int_globale_sfra/package.json int_globale_sfra/hooks.json

Hook Name

Hook Script

Description

dw.system.request.onRequest

int_globale_sfra/cartridge/scripts/hooks/request/OnRequest

Performs Main Global‑e Initialization on every storefront request

dw.order.calculate

int_globale_sfra/cartridge/scripts/hooks/cart/calculate.js

Performs Cart/Basket prices recalculation

dw.order.createOrderNo

int_globale_sfra/cartridge/scripts/hooks/order.js

Returns SFCC order number to be used durng order creation.

dw.ocapi.shop.basket.beforePATCH

int_globale_sfra/cartridge/scripts/hooks/basket.js

The function is called before updating of the basket.

dw.ocapi.shop.basket.coupon.beforePOST

int_globale_sfra/cartridge/scripts/hooks/basket/coupon.js

The function is called before adding a coupon to a basket.

dw.ocapi.shop.basket.coupon.beforeDELETE

int_globale_sfra/cartridge/scripts/hooks/basket/coupon.js

The function is called before removing a coupon from a basket.

dw.ocapi.shop.order.beforePOST

int_globale_sfra/cartridge/scripts/hooks/order.js

The function is called before an order is created for the basket.

dw.ocapi.shop.order.afterPOST

int_globale_sfra/cartridge/scripts/hooks/order.js

The function is called after an order was created from the basket.

Custom Hooks

Description

The custom hook is invoked before the SendCart request. OOTB the custom hook handler is not defined.

Note: be careful with the hook handler since it allows modifying the payload object before the SendCart request which might lead to the SendCart API error (in this case the Global‑e checkout is not loaded).

Custom hooks handler arguments

Argument Name

Argument Type

Description

basket

dw.order.Basket

The customer’s basket

payload

Object

SendCart payload object

Returns

Void.

Description

The custom hook is invoked once Global‑e sends a customer registration request (additional configuration is required on the Global‑e side for this feature). Out-of-the-box, the custom hook handler creates the SFCC account, assigns the last order to the customer and creates addresses in the SFCC address book.

Custom hooks handler arguments

Argument Name

Argument Type

Description

payload

Object

The request payload

Returns

Returns customer registration status (e.g., { success: true, registered: true, errorCode: null, eventName: 'register' }).

Description

The custom hook is invoked once Global‑e sends a customer verification request (additional configuration is required on the Global‑e side for this feature). Out-of-the-box, the custom hook handler checks if a customer has the SFCC account.

Custom hooks handler arguments

Argument Name

Argument Type

Description

payload

Object

The request payload

Returns

Returns customer verification status (e.g., { success: true, registered: false, errorCode: null, eventName: 'status' }).

Description

The custom hook is invoked before the SendCart request and could be used to return the AllowDirectCommunicationFromMerchant value. Out-of-the-box, the custom hook handler returns false.

Returns

The hook handler must return a boolean value.

Description

The custom hook is invoked before the SendCart request and could be used to return the AllowMailsFromMerchant value. Out-of-the-box, the custom hook handler returns false.

Returns

The hook handler must return a boolean value.

Description

The custom hook is invoked before the SendCart request and could be used to return the customer cookie consent. Out-of-the-box, the custom hook handler returns 1 or 0 depending on if a customer has accepted the cookies consent.

Returns

The hook handler must return an integer value. The possible values are:

  • 0 - No consent

  • 1 - Consent to all cookies

  • 2 - Consent to the essential cookies only

Description

The custom hook is invoked before the SendCart request and should be used to return all the customer’s addresses (logged-in checkout scenario). Out-of-the-box, the custom hook handler returns all the addresses that are stored in the SFCC customer’s address book.

Custom hooks handler arguments

Argument Name

Argument Type

Description

basket

dw.order.Basket

The customer’s basket

Returns

The hook handler must return null or the array of all customer’s addresses.

Description

The custom hook is invoked before the SendCart request and should be used to pre-populate the customer’s email field in the Global‑e checkout (guest checkout scenario). Out-of-the-box, the custom hook handler returns null.

Custom hooks handler arguments

No arguments are submitted to the hook handler.

Returns

The hook handler must return the guest customer email address if it was filled in by the customer before proceeding to the Global‑e checkout or null.

Description

The custom hook is invoked before the SendCart request and could be used to return the HubId value. Out-of-the-box, the custom hook handler returns null or Global-e Hub ID(if the proper setting is enabled on the Global-e side).

Returns

The hook handler must return a boolean value.

Description

The custom hook is invoked before the SendCart request for each product line item in the basket and could be used to extend the Global‑e ProductLineItem Metadata property in the SendCart payload. It might be helpful in case some additional product line item-related data should be restored if Global‑e invokes the fallback order creation scenario (an order is created from a new basket and all the original product line item custom attributes are lost in this case) or in the case if it’s required to pass additional metadata (flash sale products, etc.). Out-of-the-box, the custom hook handler returns an empty object.

Custom hooks handler arguments

Argument Name

Argument Type

Description

productLineItem

dw.order.ProductLineItem

Product line item

Returns

The hook handler must return null or the object (e.g., { key1: “value1“, key2: “value2“ }).

Description

The custom hook is invoked before the SendCart request for each product line item in the basket and could be used to return the estimated delivery date value. Allows displaying a new template for delivery date estimation (preorder/backorder products). The notification will be displayed next to the product, like product attributes. Out-of-the-box, the custom hook handler returns null.

Custom hooks handler arguments

Argument Name

Argument Type

Description

productLineItem

dw.order.ProductLineItem

Product line item

Returns

The hook handler must return null or the string value using the format “YYYY-MM-DD“ (e.g., 2022-05-15).

Description

The custom hook is invoked for setting hub code on the product level of the SendCart request body. Out-of-the-box, the custom hook handler is not defined.

Custom hooks handler arguments

Argument Name

Argument Type

Description

productLineItem

dw.order.ProductLineItem

Product line item

Returns

The hook handler must a return string value.

Description

The custom hook is invoked before the SendCart request for each product line item in the basket and could be used to return the IsBackOrdered value. Out-of-the-box, the custom hook handler returns false.

Custom hooks handler arguments

Argument Name

Argument Type

Description

productLineItem

dw.order.ProductLineItem

Product line item

Returns

The hook handler must return boolean value.

Description

The custom hook is invoked when it is needed to get the product’s image URL (before the SendCart request and on a run of SFCC job GlobaleCatalogFeed). Out-of-the-box, the custom hook handler returns a null value.

Custom hooks handler arguments

Argument Name

Argument Type

Description

product

dw.catalog.Product

SFCC product

Returns

Returns the URL of the product or null.

Description

The custom hook is not invoked if enabled site preference Use Custom Product Inventory Lists. Out-of-the-box, the custom hook handler returns a null value.

Custom hooks handler arguments

Argument Name

Argument Type

Description

product

dw.catalog.Product

SFCC product

Returns

Returns the ID of the inventory list or null.

Description

The custom hook is invoked before the SendCart request and could be used to extend the Global‑e UrlParameters SendCart payload property. It might be helpful in case some additional basket-related data should be restored if Global‑e invokes the fallback order creation scenario (an order is created from a new basket and all the original basket custom attributes are lost in this case). Out-of-the-box the custom hook handler returns an empty object.

Custom hooks handler arguments

Argument Name

Argument Type

Description

basket

dw.order.Basket

The customer’s basket

Returns

The hook handler must return null or the object (e.g., { key1: “value1“, key2: “value2“ }).

Description

The custom hook is invoked only if the Mixed Orders feature is used and right after processing the Global-e Order Create request on the SFCC side. Out-of-the-box the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

isBasketExist

Boolean

The flag which indicates the state of the SFCC basket.

payload

Object

The request payload (could have a different structure depending on if it’s the default or fallback order creation scenario).

Returns

Void

Description

The custom hook is invoked right after an order is created on the SFCC side (could be triggered not only on the OrderClientCreate request but also on the SendOrderToMerchant request if the fallback order creation scenario is applied). Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload (could have different structure depending on if it’s the default or fallback order creation scenario)

Returns

Void.

Description

The custom hook is invoked right after the order RMA information is updated on the SFCC side (RMA request). Out-of-the-box, the custom hook handler is not implemented. Could be used to apply any required custom logic when Global‑e sends an order RMA request.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked right after an order payment status is updated on the SFCC side (PaymentNotification request). Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked right after mixed orders payment statuses are updated on the SFCC side (PaymentNotification request). Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orders

dw.util.ArrayList

Array of orders (main and suborders)

payload

Object

The request payload

Returns

Void

Description

The custom hook is invoked right after an order is placed on the SFCC side. Out-of-the-box, the custom hook handler updates the customer cookie consent information.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order.

payload

Object

The request payload (could have a different structure depending on if it’s the default or fallback order creation scenario).

Returns

Void

Description

The custom hook is invoked right after the order refund information is updated on the SFCC side (OrderRefund request). Out-of-the-box, the custom hook handler is not implemented. Could be used to apply any required custom logic when Global‑e sends an order refund request.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked right after the order shipping information is updated on the SFCC side (OrderShippingInfoUpdate request). Out-of-the-box, the custom hook handler is not implemented. Could be used to apply any required custom logic when Global‑e sends order shipping information update request.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked right after the order status is updated on the SFCC side (OrderStatusUpdate request). Out-of-the-box, the custom hook handler is not implemented. Could be used to apply any required custom logic when Global‑e sends order status update request.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked right after the status of the mixed orders is updated on the SFCC side (OrderStatusUpdate request). Out-of-the-box, the custom hook handler is not implemented. It could be used to apply any required custom logic when Global-e sends an order status update request.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orders

dw.util.ArrayList

Array of orders (main and suborders)

payload

Object

The request payload

Returns

Void

Description

The custom hook is invoked right after mixed orders are updated on the SFCC side (SendOrderToMerchant request). Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orders

dw.util.ArrayList

Array of orders (main and suborders)

payload

Object

The request payload

Returns

Void

Description

The custom hook is invoked right after an order is updated on the SFCC side (SendOrderToMerchant request). Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload

Returns

Void.

Description

The custom hook is invoked before the Apply Coupon Code SFCC OCAPI request (the feature requires additional configuration on both Global‑e and SFCC sides). Out-of-the-box, the custom hook handler is not implemented. Could be used to add additional payload data or the request headers.

Custom hooks handler arguments

Argument Name

Argument Type

Description

service

dw.svc.Service

SFCC service

payload

Object

The Apply Coupon Code SFCC OCAPI request payload

Returns

Void.

Description

The custom hook is invoked right before an order is placed on the SFCC side. Out-of-the-box, the custom hook handler updates the customer cookie consent information.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload (could have a different structure depending on if it’s the default or fallback order creation scenario).

Returns

Void

Description

The custom hook is invoked before the Remove Coupon Code SFCC OCAPI request (the feature requires additional configuration on both Global‑e and SFCC sides). Out-of-the-box, the custom hook handler is not implemented. Could be used to add additional payload data or the request headers.

Custom hooks handler arguments

Argument Name

Argument Type

Description

service

dw.svc.Service

SFCC service

payload

Object

The Remove Coupon Code SFCC OCAPI request payload

Returns

Void.

Description

The custom hook is invoked right after the basket is recreated on the SFCC side. Out-of-the-box, the custom hook handler is not implemented.

Custom hooks handler arguments

Argument Name

Argument Type

Description

order

dw.order.Order

SFCC Order

payload

Object

The request payload (could have a different structure depending on if it is the default or fallback order creation scenario).

Returns

Void

Description

The custom hook is invoked after the integration initialization (on the first customer visit or when the country/currency is changed). Out-of-the-box, it is used to recalculate basket prices for the SGJC architecture.

Custom hooks handler arguments

No arguments are submitted to the hook handler.

Returns

Void. The hook handler result is not used further.

Description

The custom hook is not invoked OOTB, instead should be used to initiate OrderDispatchUpdate notification from SFCC to Global‑e (if the feature is in the integration scope). Out-of-the-box, the custom hook handler creates notification custom object that is processes by the GlobaleOrderNotifications job further.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orderId

String

The notification order number

payload

Object

The notification payload

Returns

Returns the notification creation status (dw.system.Status).

Description

The custom hook is not invoked OOTB, instead should be used to initiate OrderRefundUpdate notification from SFCC to Global‑e (if the feature is in the integration scope). Out-of-the-box the custom hook handler creates notification custom object that is processes by the GlobaleOrderNotifications job further.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orderId

String

The notification order number

payload

Object

The notification payload

Returns

Returns the notification creation status (dw.system.Status).

Description

The custom hook is not invoked OOTB, instead should be used to initiate OrderRMAUpdate notification from SFCC to Global‑e (if the feature is in the integration scope). Out-of-the-box, the custom hook handler creates notification custom object that is processes by the GlobaleOrderNotifications job further.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orderId

String

The notification order number

payload

Object

The notification payload

Returns

Returns the notification creation status (dw.system.Status).

Description

The custom hook is not invoked OOTB, instead should be used to initiate OrderStatusUpdate notification from SFCC to Global‑e (if the feature is in the integration scope). Out-of-the-box, the custom hook handler creates notification custom object that is processes by the GlobaleOrderNotifications job further.

Custom hooks handler arguments

Argument Name

Argument Type

Description

orderId

String

The notification order number

payload

Object

The notification payload

Returns

Returns the notification creation status (dw.system.Status).

Description

The custom hook is invoked on the ValidateCart request that is sent by Global‑e once a customer clicks the “Place Order“ CTA to check if all the products are still in stock. Out-of-the-box, the custom hook handler logic can check product availability using the SFCC inventory lists. Depending on the configuration can check the product availability using ProductMgr or in the OCAPI basket context.

Custom hooks handler arguments

Argument Name

Argument Type

Description

payload

Object

ValidateCart payload object

Returns

The hook handler must return the object that contains these properties: errorCode, errorMessage, amendedProducts, reservationRequestId (e.g., { errorCode: null, errorMessage: null, amendedProducts: [], reservationRequestId: null }).

Client JS SDK

On all pages of your storefront, it's mandatory to load Global‑e Client JS SDK. The Global‑e Client JS SDK is needed for showing the Welcome pop-up, Global‑e standard (default) Country Switcher and Global‑e Checkout, but it also gathers some important analytics data for Global‑e.

Here is the list of URL endpoints where the Global‑e Client JS SDK will be loaded from, depending on which Global‑e instance is connected to the Merchant environment:

Global‑e Instance

SFCC Instance

Global‑e hostname

Global‑e Client JS SDK URI

Staging

Sandbox, Development, Staging

https://www2.bglobale.com

/merchant/clientsdk/{merchantId}

Staging with CDN

-

https://stgservices.bglobale.com

Production

Production

https://web.global-e.com

Production with CDN

-

https://webservices.global-e.com

Additionally to the full URL, the Global‑e Client SDK API version parameter will be added (stored in GLOBALE_APP_SETTINGS, Custom Object, "Web Client Version" attribute). Any Global‑e function, which is defined in Client JS SDK can be called (executed) only when the Client JS SDK itself is loaded and the following JavaScript functions are triggered:

Global‑e Client JS SDK Initialization

GlobalE.SetMerchantParameters({client_settings}); // JSON object

GlobalE.ScriptsURL("Global‑e_client_js_sdk_hostname"); // for ex. https://www2.bglobale.com

GlobalE.SetCookieDomain("site_cookie_domain"); // for ex. www.site.com

More details about Global‑e Client JS SDK, available commands and functions are in Global‑e Client SDK online document.

Welcome pop up

Standard Global‑e welcome pop-up can be initialized by executing the JavaScript function:

Global‑e Welcome Pop-Up
GlobalE.LoadWelcome("US", "en-US", "USD");

It is triggered in int_globale_{architecture}/cartridge/client/default/js/geScriptLoader.js file.

Country Switcher

Standard Global‑e Country Switcher can be initialized by executing the JavaScript function:

Global‑e Country Switcher

GlobalE.LoadShippingSwitcher("US", "en-US", "USD", false);

It is triggered in int_globale_{architecture}/cartridge/client/default/js/geScriptLoader.js file.

Global‑e Checkout

Global‑e Checkout is loading in an iframe within standard SFCC container (by default int_globale_{architecture}/cartridge/templates/default/globale/checkout/iframe.isml):

Global‑e Checkout

GlobalE.Checkout("cart_token", "id_wrapper_tag");