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:

  1. 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.
  2. Inherit the EcommerceCalculatorBase class.
    Your custom order calculator class must inherit the EcommerceCalculatorBase class.
  3. Implement the IOrderCalculator interface, by implementing CalculateAndSaveChanges method.
  4. 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.
  5. Register the custom order calculator.
    In the Global.asax file, register the custom order calculator in the following way:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?