Class ShopperContext

The class represents Shopper Context. It is used to manage personalized shopping experiences on your storefront.

Shopper Context is used to personalize shopper experiences with context values such as custom session attributes, assignment qualifiers, geolocation, clientIP address, effective date time, source code, coupon code and customer groups.

When Shopper Context is set for a shopper, the context is applied in the next request and can activate promotions or price books assigned to customer groups, source codes, or stores (via assignments). Also see: ShopperContextMgr

PropertyDescription
assignmentQualifiers: MapReturns the assignment qualifiers from the Shopper Context.
clientIP: StringReturns the IP address of the client from the Shopper Context.
couponCodes: SetReturns the Coupon codes from the Shopper Context.
customQualifiers: MapReturns the custom qualifiers from the Shopper Context.
customerGroupIDs: SetReturns customer group IDs from the Shopper Context to apply.
effectiveDateTime: DateReturns the effective date time from the Shopper Context.
geolocation: GeolocationReturns the geographic location from the Shopper Context.
sourceCode: StringReturns the source code from the Shopper Context.
ConstructorDescription
ShopperContext()Constructor for ShopperContext.
MethodDescription
getAssignmentQualifiers()Returns the assignment qualifiers from the Shopper Context.
getClientIP()Returns the IP address of the client from the Shopper Context.
getCouponCodes()Returns the Coupon codes from the Shopper Context.
getCustomQualifiers()Returns the custom qualifiers from the Shopper Context.
getCustomerGroupIDs()Returns customer group IDs from the Shopper Context to apply.
getEffectiveDateTime()Returns the effective date time from the Shopper Context.
getGeolocation()Returns the geographic location from the Shopper Context.
getSourceCode()Returns the source code from the Shopper Context.
setAssignmentQualifiers(Map)Sets the assignment qualifiers in the Shopper Context.
setClientIP(String)Sets the IP address of the client in the Shopper Context.
setCouponCodes(Set)Sets the Coupon codes in the Shopper Context.
setCustomQualifiers(Map)Sets the session custom attributes as custom qualifiers in the Shopper Context.
setCustomerGroupIDs(Set)Sets the customer group IDs for the Shopper Context to apply.
setEffectiveDateTime(Date)Sets the effective date time for the context to apply.
setGeolocation(Geolocation)Sets the geographic location of the client in the Shopper Context.
setSourceCode(String)Sets the source code for the Shopper Context to apply.

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

assignmentQualifiers: Map

Returns the assignment qualifiers from the Shopper Context. Assignment qualifiers are set when using the assignment framework to trigger pricing and promotion experiences for Products, Product Search, Basket, Shipping methods etc.


clientIP: String

Returns the IP address of the client from the Shopper Context.


couponCodes: Set

Returns the Coupon codes from the Shopper Context.


customQualifiers: Map

Returns the custom qualifiers from the Shopper Context. Custom qualifiers contain the custom session attributes set in the Shopper Context.


customerGroupIDs: Set

Returns customer group IDs from the Shopper Context to apply. The customer group IDs set in Shopper Context evaluate to customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.


effectiveDateTime: Date

Returns the effective date time from the Shopper Context. With the effective date time you can retrieve promotions that are active at a particular time. For example, "Shop the Future" use cases.


geolocation: Geolocation

Returns the geographic location from the Shopper Context.


sourceCode: String

Returns the source code from the Shopper Context. The source code set in Shopper Context evaluates to source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).


ShopperContext()

Constructor for ShopperContext.

This constructor is used to create an empty object. The object will be empty and must be populated with the appropriate setter methods. For example:


getAssignmentQualifiers(): Map

Returns the assignment qualifiers from the Shopper Context. Assignment qualifiers are set when using the assignment framework to trigger pricing and promotion experiences for Products, Product Search, Basket, Shipping methods etc.

Returns:

  • A map of assignment qualifiers set in the Shopper Context.

getClientIP(): String

Returns the IP address of the client from the Shopper Context.

Returns:

  • The IP address of the client set in the Shopper Context.

getCouponCodes(): Set

Returns the Coupon codes from the Shopper Context.

Returns:

  • The Coupon codes set in the Shopper Context.

getCustomQualifiers(): Map

Returns the custom qualifiers from the Shopper Context. Custom qualifiers contain the custom session attributes set in the Shopper Context.

Returns:

  • A map containing the custom qualifiers set in the Shopper Context.

getCustomerGroupIDs(): Set

Returns customer group IDs from the Shopper Context to apply. The customer group IDs set in Shopper Context evaluate to customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.

Returns:

  • The customer group IDs for the Shopper Context to apply.

getEffectiveDateTime(): Date

Returns the effective date time from the Shopper Context. With the effective date time you can retrieve promotions that are active at a particular time. For example, "Shop the Future" use cases.

Returns:

  • The effective date time in UTC for the Shopper Context to apply.

getGeolocation(): Geolocation

Returns the geographic location from the Shopper Context.

Returns:

  • The geographic location set in the Shopper Context.

getSourceCode(): String

Returns the source code from the Shopper Context. The source code set in Shopper Context evaluates to source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).

Returns:

  • The source code for the Shopper Context to apply.

setAssignmentQualifiers(assignmentQualifiers: Map): void

Sets the assignment qualifiers in the Shopper Context. Assignment qualifiers are set when using the assignment framework to trigger pricing and promotion experiences for Products, Product Search, Basket, Shipping methods etc.

**Example: Assignment qualifier for store can be set as follows: **

Parameters:

  • assignmentQualifiers - A map which contains the assignment qualifiers to save in the Shopper Context.

setClientIP(clientIP: String): void

Sets the IP address of the client in the Shopper Context. The client IP evaluates to a geolocation. If the client IP address is not a valid IPv4/IPv6 address an error is thrown.

Parameters:

  • clientIP - The IP Address of the client to set in the Shopper Context.

setCouponCodes(couponCodes: Set): void

Sets the Coupon codes in the Shopper Context. When you set coupon codes, it is saved as context for subsequent requests and can then trigger promotions via the campaign which are tied to the coupon. A maximum of 5 coupon codes can be set in the ShopperContext.

Parameters:

  • couponCodes - The set of coupon codes to set in the Shopper Context. A maximum of 5 coupon codes per ShopperContext are allowed.

setCustomQualifiers(customQualifiers: Map): void

Sets the session custom attributes as custom qualifiers in the Shopper Context. Custom qualifiers are set when you want to trigger pricing and promotion experiences using a dynamic session-based customer groups.

**Example: A session custom attribute 'device_type' can be saved as follows: **

Parameters:

  • customQualifiers - A map which contains the custom session attributes to save in the Shopper Context.

setCustomerGroupIDs(customerGroupIDs: Set): void

Sets the customer group IDs for the Shopper Context to apply. Set the customer group IDs to evaluate customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.

Parameters:

  • customerGroupIDs - The customer group IDs for the Shopper Context to apply.

setEffectiveDateTime(effectiveDateTime: Date): void

Sets the effective date time for the context to apply. With the effective date time you can retrieve promotions that are active at a particular time. For example, "Shop the Future" use cases.

Parameters:

  • effectiveDateTime - The effective date time to set in the Shopper Context.

setGeolocation(geolocation: Geolocation): void

Sets the geographic location of the client in the Shopper Context. When you set a geolocation, it is saved as context for subsequent requests. This overrides any context previously saved using clientIP in the Shopper Context.

Parameters:

  • geolocation - The geographic location of the client to set in the Shopper Context.

setSourceCode(sourceCode: String): void

Sets the source code for the Shopper Context to apply. Set the source code to evaluate source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).

Parameters:

  • sourceCode - The source code to set in the Shopper Context.