Skip to main content

setCustomerInfo()

setCustomerInfo(customerInfo): Promise<Success>

This method hands Growave the profile of the signed-in customer.

It is meant for headless storefronts. On a Shopify theme the profile is read from the markup Growave renders, but a headless page has no such markup, so Growave asks its own API for it instead. A profile supplied here takes precedence over that request. Supply it before the customer is authenticated for the first time and that request is never made; supplied afterwards, it replaces a request that has already gone out. When a different customer signs in, one request for the outgoing customer is unavoidable whatever the order.

Call it after init(). Before that the SDK has nothing to hand the profile to, and the promise rejects with an internal resolution error rather than the validation error described below.

The identity always comes from the Growave token, never from this call: the id must be the Shopify customer the token was issued for, otherwise the profile is ignored without an error. Call it again whenever a different customer signs in.

One limitation to know about on a headless storefront: whether the customer is B2B is decided once, from the first settled answer, and rewards widgets are chosen accordingly. A customer who signs in on a page that started as a guest therefore gets the retail widgets until the next page load. Pass growaveToken to init() when you already hold one, and the very first answer is the right one.

Every field listed below is required. The returned promise rejects when one is missing or has the wrong type, so await the call or attach a catch. Fields Growave does not know are ignored.

Parameters​

ParameterTypeDescription
customerInfoCustomerInfoSdkDtoProfile of the currently authenticated customer.

Returns​

Promise<Success>

Example​

Supplying the profile first lets Growave skip its own request for it. Both calls belong after init() — wait for the SDK the same way you do there.

await window.gw.sdk.common.methods.setCustomerInfo({
id: shopifyCustomerId,
email: "buyer@example.com",
firstName: "Ada",
lastName: "Lovelace",
isB2b: false,
tags: ["vip"],
company: null,
});

await window.gw.sdk.authentication.methods.authenticateCustomer({
shopifyCustomerId,
signature,
signatureTimestamp,
});