ShopperContext
ShopperContextErrorCodes
ShopperContextException
ShopperContextMgr
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
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
| Property | Description |
|---|---|
| assignmentQualifiers: Map | Returns the assignment qualifiers from the Shopper Context. |
| 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. |
| customerGroupIDs: Set | Returns customer group IDs from the Shopper Context to apply. |
| effectiveDateTime: Date | Returns the effective date time from the Shopper Context. |
| geolocation: Geolocation | Returns the geographic location from the Shopper Context. |
| sourceCode: String | Returns the source code from the Shopper Context. |
| Constructor | Description |
|---|---|
| ShopperContext() | Constructor for ShopperContext. |
| Method | Description |
|---|---|
| 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
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 the IP address of the client from the Shopper Context.
Returns the Coupon codes from the Shopper Context.
Returns the custom qualifiers from the Shopper Context. Custom qualifiers contain the custom session attributes set in the Shopper Context.
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 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 geographic location from the Shopper Context.
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).
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:
1ShopperContext context = new ShopperContext();
2context.setSourceCode( "sourcecode" );
3ShopperContextMgr.setShopperContext( context, true );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:
Returns the IP address of the client from the Shopper Context.
Returns:
Returns the Coupon codes from the Shopper Context.
Returns:
Returns the custom qualifiers from the Shopper Context. Custom qualifiers contain the custom session attributes set in the Shopper Context.
Returns:
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:
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:
Returns the geographic location from the Shopper Context.
Returns:
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:
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: **
1var assignmentQualifiers = new dw.util.HashMap();
2 assignmentQualifiers.put( "storeId", "Boston" );
3 ShopperContext context = new ShopperContext();
4 context.setAssignmentQualifiers( customQualifiers );
5 ShopperContextMgr.setShopperContext( context, true );Parameters:
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:
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:
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: **
1var customQualifiers = new dw.util.HashMap();
2 customQualifiers.put( "deviceType", "iPad" );
3 ShopperContext context = new ShopperContext();
4 context.setCustomQualifiers( customQualifiers );
5 ShopperContextMgr.setShopperContext( context, true );Parameters:
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:
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:
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:
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: