setGlobalProductId()
setGlobalProductId(
productId):Promise<Success>
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.
Parameters
| Parameter | Type | Description |
|---|---|---|
productId | number | Product ID to set as global. |
Returns
Promise<Success>
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);
}