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.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. 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?