Order Subtotal Discount

The Order Subtotal Discount applies discounts to the order subtotal. The amount of the subtotal is distributed across the line items in the basket. To handle refunds properly, order level discounts should be distributed across all line items. Commerce Server 2002 distributes percentage off discounts and dollar off discounts.

For example, a 10 percent discount is offered to preferred shoppers on the following order:

  • Four books at $25 each = $100

If the discount is only applied to the final price, the receipt will look like the following:

Item Amount
Book #1 25.00
Book #2 25.00
Book #3 25.00
Book #4 25.00
Subtotal 100.00
Discount (10.00)
Total 90.00

In this example, a shopper who returns one of the books will get a full refund of 25 dollars. However, the shopper did not pay 25 dollars for each book. The shopper actually paid 22.50 for each book, because of the 10 percent discount. For this reason, order level discounts should be distributed across all items in an order.

Distributing Percentage Off Discounts

The following example illustrates how percentage off discounts are distributed across the line items in the basket. In this example a 10 percent discount is offered to preferred shoppers on the following order:

  • Four books at $25 each = $100
Item Amount
Book #1 25.00
Discount (2.50)
Subtotal 22.50
Book #2 25.00
Discount (2.50)
Subtotal 22.50
Book #3 25.00
Discount (2.50)
Subtotal 22.50
Book #4 25.00
Discount (2.50)
Subtotal 22.50
Total 90.00

The final sales price does not change. However, the adjusted price of each item is recorded at 22.50, which properly reflects the discount. In this case, a shopper who returns an item will not be overpaid on the refund.

Percentage discounts round to two decimal points. Contact your site developer if you want to change the number of decimal places.

Distributing Dollar Off Discounts

To distribute dollar off discounts, the amount of each item discount is calculated and the discount is distributed across all items in the basket. Dollar off discounts use the following algorithm:

ItemDiscount = Truncate(((ItemAdjustedPrice/OrderAdjustedSubtotal)*DiscountAmount),2); 

Which is equivalent to the following:

Truncate the value: ItemAdjustedPrice/OrderAdjustedSubtotal to two decimal places; where ItemAdjustedPrice is the price of the item after it is adjusted for discounts that were applied before the order-level discount; and the OrderAdjustedSubtotal is the total order subtotal after it is adjusted for discounts that were applied before the order-level discount.

Ee785199.note(en-US,CS.20).gifNote

  • Dollar discounts round to two decimal points.

The following example illustrates how dollar off discounts are distributed across the line items in the basket. A $25.00****discount is offered to preferred users on the following order:

  • 2 shirts at $30.00 each
  • 2 pairs of pants at $50.00 each
  • 1 belt at $10.00

Following is the user basket before the $25.00 discount is applied:

User Basket

Item Quantity Unit Price Extended Price
Shirt 2 30.00 60.00
Pants 2 50.00 100.00
Belt 1 10.00 10.00
Total     170.00

Following is the user basket after the $25.00 discount is applied:

User Basket

Item Unit Price Discount Adjusted Price
First shirt 30.00 4.41 25.59
Second shirt 30.00 4.41 25.59
First pair of pants 50.00 7.35 42.65
Second pair of pants 50.00 7.35 42.65
Belt 10.00 1.47 8.52
Total 170.00 24.99 145.00

Note that the sum of the discounts equals $24.99, rather than the total $25.00 discount for the order.

Following are two approaches you can use to correct the rounding problem:

Approach 1:

Approach 1 applies the difference to the last discountable item in the items list:

If (CurrentItem = LastItemThatCanReceiveADiscount)

     If (TotalDiscountApplied < AwardAmount)

          ItemDiscount = (AwardAmount – TotalDiscountApplied)

Ee785199.note(en-US,CS.20).gifNote

  • Since the values are truncated, the TotalDiscountApplied will always be <=AwardAmount.

Approach 2:

Approach 2 calculates the following:

  1. Calculate the lowest price based on the decimal places. For example, if decimal places is equal to two, then the lowest price possible is $0.01.
  2. Start adding the "lowest price" to the discounts of the items, starting with the most expensive item first. If two items have the same "most expensive price", award it to the item that has the "lowest basket index".
  3. Subtract this amount from the discount error.
  4. Repeat steps 2 and 3 until the discount error becomes zero (0).

The following shows how the discount of $25.00 is applied using Approach 1.

  • 2 shirts at $30.00 each
  • 2 pairs of pants at $50.00 each
  • 1 belt at $10.00

User Basket

Item Unit Price Discount Adjusted Price
First shirt 30.00 4.41 25.59
Second shirt 30.00 4.41 25.59
First pair of pants 50.00 7.35 42.65
Second pair of pants 50.00 7.35 42.65
Belt 10.00 1.48 8.52
Total 170.00 25.00 145.00

In the above example, the belt is the last item that can receive a discount. Therefore, the extra $.01 (discount error) is added to the belt award for a total of $1.48 (1.47+.01), which brings the discount to the $25.00 total for the order.

The following is an additional example of how dollar off discounts are applied using Approach 1.

  • Buy anything
  • Get an order-level discount of $5.00

User Basket

Basket Index Item Unit Price Discount Adjusted Price
1 Item 1 7.50 2.49 5.01
2 Item 1 7.50 2.49 5.01
3 Item 3 0.01 0.00 0.01
Total   15.01 4.98 10.03

In this example, note that the sum of the discounts equals $4.98, rather than the total $5.00 discount for the order.

The following shows how the discount in the example above will be applied using Approach 1.

User Basket

Basket Index Item Unit Price Discount Adjusted Price
1 Item 1 7.50 2.49 5.01
2 Item 1 7.50 2.51 4.99
3 Item 3 0.01 0.00 0.01
Total   15.01 5.00 10.01

In the above example, Item 1 in Basket Index 2 is the last item that can receive a discount (Item 3 cannot be discounted by $0.02 because its price is only $0.01). Therefore, the extra $.02 (discount error) is added to Item 1 in Basket Index 2 for a total of $2.51, which brings the discount to the $5.00 total for the order.

Following are some inferences with using Approach 1:

  • Basket Indexes 1 and 2 contain the same Item number (with the same price). However, they have different discounts.
  • No discount is applied to Item 3.
  • Because Item 1 and Item 2 are the same price, if Item 1 is returned, do you refund the user $5.01 or $4.99?

The following shows how the discount in the example above will be applied using Approach 2.

User Basket

Basket Index Item Unit Price Discount Adjusted Price
1 Item 1 7.50 2.50 5.00
2 Item 1 7.50 2.50 5.00
3 Item 3 0.01 0.00 0.01
Total   15.01 5.00 10.01

The adjusted price of each item is recorded, and the user will receive the $5.00 discount. Both Items in Basket Index 1 and 2 receive the same discount, so if one of the Items is returned, the refund will be the same for both Items.

Ee785199.note(en-US,CS.20).gifNote

  • In the above example, the OrderDiscountApply pipeline component is used to apply the discount. For information about the OrderDiscountApply component, see the "OrderDiscount" topic in the Commerce Server 2002 Help Programmer's Reference.

See Also

Processing Discounts

Components of a Discount

Creating a Discount

Copyright © 2005 Microsoft Corporation.
All rights reserved.