This topic describes how to create a volume discount promotion in Episerver Commerce. This discount has only a MinOrderAmount custom variable, which qualifies or disqualifies the discount.
Note: This functionality is obsolete and will be removed in a future release. It is being replaced by the new Marketing system.
How it works
The implementation consists of the following steps:
- Create the expression rules.
- Create and test the user interface for administering the volume discount.
- Create unit tests for testing the promotion.
- Test the promotion.
Classes in this topic are available in the following namespaces:
This step results in an XML document that the back-end uses to create the actual discount record.
The XML Rule Set should consist of these rules:
- SetupConstants. Sets up a constant in the current runtime context that the rules engine can use. The constant name should be $MinOrderAmount.
- CheckOrderSubTotal. Validates current order subtotal and compares it to the constant specified. Use the SourceEntriesSet.TotalCost property instead of Cart.SubTotal.
- AssignReward. Adds a new PromotionItemRecord with a reward of type WholeOrder.
Note: The rule should be executed only once against the full order. Compare this to a line item type of discount, where a rule is executed for each line item in the order.
The result of this step is a screen that lets the store administrator create a new Volume Type discount.
- Create a new file Apps\Marketing\Promotions\Configs\OrderVolumeDiscount.config. Specify the following parameters:
- Type: OrderVolumeDiscount
- Name: Order, Sub, Total, Volume, Discount
- Description: This type of promotion discounts the order subtotal if minimum order amount is met.
- Group: order
- Path: OrderVolumeDiscount\ConfigControl.ascx
- Expression: enter the expression generated in Step 1.
- Create new file Apps\Marketing\Promotions\OrderVolumeDiscount\ConfigControl.ascx. You can use the other PairedPromotion discount as a template. The UI should include two fields:
- Min. Order Amount
- Amount (exists in PairedPromotion)
- Modify the Settings class to include MinOrderAmount and remove unused properties.
- Test the administration user interface.
The result of this step is a set of unit tests that validate that the promotion engine and specific discount work correctly.
- Create 3 promotions with a MinOrderAmount of 1000, 2000, and 3000. They will give the discounts 5%, 10% and 15%.
- Create a new class: CommerceLibTest\MarketingSystem\MarketingSystem_OrderVolumePromotion.cs.
- Create a new method: MarketingSystem_OrderVolumePromotion_10PercentOff(). This method should create a new SourceEntriesSet and TargetEntriesSet with an item Total amount equal to 2000. The method should execute the promotion engine and check the reward. It should equal to 200. If this is not fulfilled, it should throw an exception.
- Go to the front-end website.
- Add products so the total adds up to more than 1000.
- Go to the shopping cart. The total volume discount promotion appears.
Last updated: Oct 24, 2016