Create a custom order calculator
The IOrderCalculator interface allows you to do every calculation related to the order by yourself. Although this is not a trivial task to do (to take over calculations), it gives you the flexibility to do anything you want with the calculation mechanism.
NOTE: Using a custom implementation of the IOrderCalculator interface overrides the build-in calculations done by the Ecommerce module. This means you have to perform all the calculations by yourself.
To create a custom order calculator, you must perform the following:
- Create a class for your custom order calculator.
Create a class that will represent the order calculator. In this example the name CustomOrederCalculator is used.
- Inherit the EcommerceCalculatorBase class.
Your custom order calculator class must inherit the EcommerceCalculatorBase class.
- Implement the IOrderCalculator interface, by implementing
- Implement the CalculateAndSaveChanges method.
In this method you can perform manually all the calculations regarding the order. As an argument you receive the cart order.
- Register the custom order calculator.
In the Global.asax file, register the custom order calculator in the following way: