getShopifyCustomerId()
getShopifyCustomerId():
number|null
Returns the Shopify customer ID from the current token.
Returns
number | null
The Shopify customer ID if authenticated, or null if not authenticated or token is invalid.
Remark
Use this method to check if a customer is already authenticated before calling setToken().
This helps avoid unnecessary token overwrites in storage.
Example
window.gw.sdk.runIfModuleReady(
window.gw.sdk.common.constants.modules.AUTHENTICATION,
() => {
const currentCustomerId = window.gw.sdk.authentication.methods.getShopifyCustomerId();
if (currentCustomerId !== newCustomerId) {
window.gw.sdk.authentication.methods.setToken(token);
}
}
);