getShopifyCustomerId
Returns the Shopify customer ID from the current token.
Use this method to check if a customer is already authenticated before calling setToken(). This helps avoid unnecessary token overwrites in storage.
sdk.authentication.methods.getShopifyCustomerId()getShopifyCustomerId(): number | null
Returns
number | nullThe Shopify customer ID if authenticated, or `null` if not authenticated or token is invalid.
Usage 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);
}
}
);