HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Calculate orders

Describes the components involved when calculating orders in Optimizely Commerce (PaaS).

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

Improvements in the workings of calculators

[New in Commerce (PaaS) 12]

The order calculation functionality was improved according to the following.

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 (PaaS) 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 (PaaS) retains tax information for processing the order later.

Storing results in relevant objects

In Commerce (PaaS) 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 recalculated 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.