Class ShopperContext
dw.customer.shoppercontext
Class ShopperContext
Object
dw.customer.shoppercontext.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 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).

Properties
assignmentQualifiers  :  Map
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
The IP address of the client from 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.
customQualifiers  :  Map
The custom qualifiers from the Shopper Context. Custom qualifiers contain the custom session attributes set in the Shopper Context.
effectiveDateTime  :  Date
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
The geographic location from the Shopper Context.
sourceCode  :  String
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).
Constructor Summary
ShopperContext()
Constructor for ShopperContext.
Method Summary
getAssignmentQualifiers() : Map
Returns the assignment qualifiers from the Shopper Context.
getClientIP() : String
Returns the IP address of the client from the Shopper Context.
getCustomerGroupIDs() : Set
Returns customer group IDs from the Shopper Context to apply.
getCustomQualifiers() : Map
Returns the custom qualifiers from the Shopper Context.
getEffectiveDateTime() : Date
Returns the effective date time from the Shopper Context.
getGeolocation() : Geolocation
Returns the geographic location from the Shopper Context.
getSourceCode() : String
Returns the source code from the Shopper Context.
setAssignmentQualifiers(assignmentQualifiers : Map) : void
Sets the assignment qualifiers in the Shopper Context.
setClientIP(clientIP : String) : void
Sets the IP address of the client in the Shopper Context.
setCustomerGroupIDs(customerGroupIDs : Set) : void
Sets the customer group IDs for the Shopper Context to apply.
setCustomQualifiers(customQualifiers : Map) : void
Sets the session custom attributes as custom qualifiers in the Shopper Context.
setEffectiveDateTime(effectiveDateTime : Date) : void
Sets the effective date time for the context to apply.
setGeolocation(geolocation : Geolocation) : void
Sets the geographic location of the client in the Shopper Context.
setSourceCode(sourceCode : String) : void
Sets the source code for the Shopper Context to apply.
Constructor Detail
ShopperContext
public 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:

 ShopperContext context = new ShopperContext();
 context.setSourceCode( "sourcecode" );
 


Method Detail
getAssignmentQualifiers
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
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.

getCustomerGroupIDs
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.

getCustomQualifiers
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.

getEffectiveDateTime
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
getGeolocation() : Geolocation
Returns the geographic location from the Shopper Context.
Returns:
The geographic location set in the Shopper Context.

getSourceCode
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
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:


  var assignmentQualifiers = new dw.util.HashMap();
  assignmentQualifiers.put( "storeId", "Boston" );
  ShopperContext context = new ShopperContext();
  context.setAssignmentQualifiers( customQualifiers );
 

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

setClientIP
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.

setCustomerGroupIDs
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.

setCustomQualifiers
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:


  var customQualifiers = new dw.util.HashMap();
  customQualifiers.put( "deviceType", "iPad" );
  ShopperContext context = new ShopperContext();
  context.setCustomQualifiers( customQualifiers );
 

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

setEffectiveDateTime
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
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
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.