How Discounts Are Added to an Order
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
Discounts can be added to an order in two situations:
When the customer provides a promotion code.
When a site-wide discount is available.
Promotions require user interaction. From your site code, you ask the user to enter promotion codes. You then add each promotion code to the PromoCodeStringCollection object that is the value of the PromoCodes property of the OrderForm object.
Site-wide discounts do not require user interaction.
In this topic, the word "discount" refers to both promotions and site-wide discounts.
The Basket pipeline, the Total pipeline, and the Checkout pipeline each contain components that affect discounts.
How the Basket Pipeline Affects Discounts
When you run the Basket pipeline, Commerce Server applies the discounts to the items in the basket. The following pipeline components in the Basket pipeline play a role in creating discounts:
ReservePromoCodes validates each promotion code in the PromoCodeStringCollection object. If the promotion is limited and the limit has almost been reached, it reserves the promotion code. The ReservePromoCodes pipeline component creates a PromoCodeRecord for each valid promotion code.
OrderDiscount (PCR) determines which discounts apply to which items. It then adjusts the cost of each item to reflect the applicable line-item discounts.
Note
Discounts can apply to individual line items (for example, 50% off holiday merchandise) or to the order as a whole (for example, 10% off all orders over $100 U.S.). The OrderDiscount pipeline component adjusts the cost of each line to reflect only the item-level discounts.
OrderLevelDiscountApply applies discounts that affect the order as a whole. It allocates a fraction of each order-level discount to each item, and adjusts the cost of the item to reflect the discount.
RecordPromoCodes updates each PromoCodeRecord object in the basket to indicate whether the promotion code is valid and whether the associated discount was applied to the order.
How the Total Pipeline Affects Discounts
When you run the Total pipeline, Commerce Server applies discounts to shipping costs. The following pipeline components in the Total pipeline play a role in creating discounts:
ShippingDiscountAdjust applies discounts to the shipping costs. For each discount that it applies, the ShippingDiscountAdjust pipeline component creates a ShippingDiscountRecord object and adds it, indirectly, to the OrderForm object.
RecordPromoCodes updates any PromoCodeRecord objects in the basket that relate to shipping costs to indicate whether the promotion was applied to the order.
How the Checkout Pipeline Affects Discounts
When you run the Checkout pipeline, Commerce Server redeems the promotion codes. The RedeemPromoCodes pipeline component validates each promotion code again. If the promotion was applied to the order, it updates the PromoCodeRecord object to indicate that the promotion was applied. If the promotion was reserved but was not applied, the RedeemPromoCodes pipeline component cancels the reservation.