How Discounts Are Applied

In a Content Selection pipeline, the ScoreDiscounts component adjusts the scores in the list of possible discounts to ensure that the most relevant discounts receive the highest priority.The OrderDiscount pipeline component in an Order pipeline applies the list of discounts to the basket of the user.

The OrderDiscount component first evaluates the requirements of the available discounts. Depending on the discount involved, it uses the user profile and context profile information to form target expressions that it evaluates. In addition, if a discount requires a click, the component checks the discounts_clicked list (a list of campaign item IDs of every item that was clicked).

For each line item in the order, the OrderDiscount component writes two keys to the item dictionary: _n_unadjusted and _cy_oadjust_adjustedprice. The first key is the quantity of the item that has not had discounts applied. The second key is the total price of the items before discounts. The _n_unadjusted key is set to the quantity of the item; the _cy_oadjust_adjustedprice key is set to the total price for the items.

The OrderDiscount component next goes through the items, testing the conditions and awards. As an item is used in a discount, the two keys (_n_unadjusted and _cy_oadjust_adjustedprice) are adjusted appropriately. Discounts are applied from highest to lowest priority. If two discounts have the same priority, the discount appearing first in the database is applied.

There may be limits to how many discounts can be applied to a basket. This limit is set in Commerce Server Business Desk. If the discount limit has a value of zero (0), discounts are unlimited. The discount limit is a basket limit and does not apply across baskets.

The OrderDiscount component uses a list to ensure integrity in the process. The component stores a list of discounts that were applied and the last time the discount was modified. If, on the next request, discounts that were applied no longer apply, the pur_dicountremoved error is added to the _Basket_Errors list.

The discount cache must be manually refreshed after changes are made to any discount. You can do this by using the Production Refresh module in Business Desk.

One way to implement discounts on your site is to accept promotional codes. First, set up the discount properties and the display information through Business Desk. Next, configure the discount definition using the Expression Builder. For example, the expression could be Context.PromoCode equals 1234. Modifications will need to be made to the source code for the site. When the basket pipeline is called, a ContextProfile dictionary (which is a sub dictionary of the Context dictonary) must be passed, and the promotional code entered must be set.

See Also

Discount Overview


All rights reserved.