Skip to main content

setGlobalProductId

This method sets a global product ID to be used as a fallback when a widget requires a product ID but none is provided. Using a global product ID ensures consistent behavior across widgets that depend on product-specific data.

sdk.common.methods.setGlobalProductId()
function
setGlobalProductId(productId: number): Promise<Success>
Parameters
productIdnumber
Product ID to set as global.
Returns
Promise<Success>

Usage example​

Ensure the SDK is ready before setting the global product ID:

function onSdkReady() {
window.gw.sdk.common.methods.setGlobalProductId(1234567890);
}

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