Last updated: Apr 16 2018

Area: Episerver Commerce Applies to versions: 12 and higher
Other versions:

Calculating orders: introduction

The following calculation services are available to calculate order totals in different levels.

Improvements in the workings of calculators

Beginning with Commerce 12, Episerver has improved how calculators work when calculating orders.

No unnecessary recalculations

Previously, calculators recalculated prices and taxes even if an order had no changes or if the changes did not affect results. This practice is inefficient, especially when using an external tax service. It also creates problems with old orders, deleted products, expired promotions, new promotions, etc. In Commerce 12, if an order has no changes that affect results, no recalculations take place. Instead, the previously-calculated values are returned.

TaxCategoryId for LineItem property

A new property, TaxCategoryId for LineItem, is available to store TaxCategoryId. So, even if a product is deleted, Commerce retains tax information for processing the order later.

Storing results in relevant objects

In Commerce 12, if calculators process many calculations, such as using an external tax service or reading from a database, the results are stored in relevant objects. As examples, if any of the below properties changes, results are re-calculated and stored with the relevant object.

  • OrderGroup/SerializableCart (calculates tax total)
    • MarketId
    • CurrencyCode
  • Shipment/SerializableShipment (calculates shipping tax and shipping cost)
    • ShippingMethodId
    • ShippingAddress
    • LineItems: adding/ removing line item
    • ShipmentDiscount
  • LineItem/ SerializableLineItem (calculates sales tax)
    • PlacedPrice
    • Quantity
    • OrderAmount
    • EntryAmount
    • TaxCategoryId

Shipment required for correct calculation

When you create an order (cart, purchase order, or payment plan) through the IOrderRepository, a shipment is created. Order calculators calculate only line items that belong to a shipment. This is a changed behavior from the way it worked with workflow activities. 

Comments