Teilen über


How to Apply Discounts Programmatically

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

In a Content Selection pipeline, the ScoreDiscounts component adjusts the scores in the list of possible discounts to make sure that the most relevant discounts receive the highest priority. The OrderDiscount (PCR) pipeline component in an Order pipeline applies the list of discounts to the customer's basket.

The OrderDiscount (PCR) 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. Additionally, 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 (PCR) 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 (PCR) 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 can be a limit to how many discounts can be applied to a basket. This limit is set in the Market Manager window. 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.

Note

The Orders System does not support the scenario where a LineItem has a negative value because of applying a discount. In this case, the Orders System will generate an exception.

The OrderDiscount (PCR) 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.

One way to implement discounts on your site is to accept promotional codes. First, set up the discount properties and the display information by using the Marketing Manager. Modifications will have to be made to the source code for the site. When the basket pipeline is called, a ContextProfile dictionary (which is part of the Context dictionary) must be passed, and the promotional code entered must be set.

Note

Discounts can only be created by authenticated users. Unauthenticated users trying to do this will be able to access the user interface, but all task links are disabled. Disable anonymous access to the Web site to solve this problem.

See Also

Other Resources

What Are Discount Elements?

Managing Campaigns