Creates the shopper's context based on shopperJWT. If a shopper context already exists, it replaces the entire existing context.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
If you would like to get a raw Response object use the other createShopperContext function.
An object containing the options for this method.
A promise of type void | void.
Creates the shopper's context based on shopperJWT. If a shopper context already exists, it replaces the entire existing context.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type void | void otherwise.
Gets the shopper's context based on the shopperJWT.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
If you would like to get a raw Response object use the other deleteShopperContext function.
An object containing the options for this method.
A promise of type void.
Gets the shopper's context based on the shopperJWT.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type void otherwise.
Gets the shopper's context based on the shopperJWT.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
If you would like to get a raw Response object use the other getShopperContext function.
An object containing the options for this method.
A promise of type ShopperContext.ShopperContext.
Gets the shopper's context based on the shopperJWT.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type ShopperContext.ShopperContext otherwise.
Updates an existing shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body.
custom qualifiers
or assignment qualifiers
:If the individual qualifier key exists, it is overwritten with the new value.
If the value of the key is set to null, it is deleted from the existing shopper context.
If an empty custom qualifiers
or assignment qualifiers
object \{\}
is passed, the entire qualifier object is deleted.
effectiveDateTime
or sourceCode
or clientIp
:If the new value is set to an empty string (""), it is deleted from the existing shopper context.
If the new value is set to null, it is ignored.
If the new value is not empty or null, it overwrites the existing value.
customerGroupIds
:If a list of customerGroupIds
exists, it is replaced by the new list of customer group IDs from the request.
If customerGroupIds
is set to an empty array [], the existing list in the shopper context is deleted.
geoLocation
:If it exists, the entire geoLocation
object is replaced with the new value.
If the new value is set to null, it is ignored.
If an empty geoLocation
object \{\}
is passed, it is deleted.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
If you would like to get a raw Response object use the other updateShopperContext function.
An object containing the options for this method.
A promise of type ShopperContext.ShopperContext.
Updates an existing shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body.
custom qualifiers
or assignment qualifiers
:If the individual qualifier key exists, it is overwritten with the new value.
If the value of the key is set to null, it is deleted from the existing shopper context.
If an empty custom qualifiers
or assignment qualifiers
object \{\}
is passed, the entire qualifier object is deleted.
effectiveDateTime
or sourceCode
or clientIp
:If the new value is set to an empty string (""), it is deleted from the existing shopper context.
If the new value is set to null, it is ignored.
If the new value is not empty or null, it overwrites the existing value.
customerGroupIds
:If a list of customerGroupIds
exists, it is replaced by the new list of customer group IDs from the request.
If customerGroupIds
is set to an empty array [], the existing list in the shopper context is deleted.
geoLocation
:If it exists, the entire geoLocation
object is replaced with the new value.
If the new value is set to null, it is ignored.
If an empty geoLocation
object \{\}
is passed, it is deleted.
With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId
parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type ShopperContext.ShopperContext otherwise.
Generated using TypeDoc
Shopper Context
The Shopper Context API enables developers to build highly contextualized shopping experiences for shoppers.
Example with shopper auth
API Version: 0.0.30import { Customer, ClientConfig, Customer, slasHelpers } from "commerce-sdk"; // or const { Customer, ClientConfig, Customer, slasHelpers } = require("commerce-sdk"); const clientConfig: ClientConfig = { parameters: { clientId: "XXXXXX", organizationId: "XXXX", shortCode: "XXX", siteId: "XX" } }; // must be registered in SLAS. On server, redirectURI is never called const redirectURI = "http://localhost:3000/callback"; const slasClient = new Customer.ShopperLogin(clientConfig); token = await slasHelpers.loginGuestUser(slasClient, { redirectURI }); clientConfig.headers['authorization'] = `Bearer ${token.access_token}`; const shopperContextClient = new Customer.ShopperContext(clientConfig);
Last Updated: