Skip to main content

Products module

The Products module may initialize at any point, depending on the setup. To ensure your code runs when the Products module is ready, use the runIfModuleReady method from the Common module, which is available immediately after the gwSdkReady event is triggered.

This code ensures the callback runs immediately if the Products module is already initialized; if not, it runs once the module is ready.

function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.PRODUCTS;

window.gw.sdk.runIfModuleReady(moduleName, () => {
// The Products module is ready for use and available at `window.gw.sdk.products`
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}