Calculate orders
Describes the components involved when calculating orders in Optimizely Commerce Connect 13.
The following calculation services are available to calculate order totals in different levels.
- Line item calculator. Calculates extended price, discounted price, line item price and sales tax for item.
- Shipping calculator. Calculates shipping cost, shipping taxes, and total amount for items in shipment.
- Tax calculator. Calculates taxes base on tax value, gets taxes value.
- Order form calculator. Calculates totals, discount total and tax total on an order form.
- Order group calculator. Calculates totals, discount total and tax total on an order.
- Return line item calculator. Calculates extended price, discounted price and sales tax for return item.
- Return order form calculator. Calculates totals, discount total and tax total on a return order form.
- Return purchase order calculator. Calculates totals, discount total on an order.
Improvements in the workings of calculators
Commerce Connect 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 Connect 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 Connect retains tax information for processing the order later.
Store results in relevant objects
In Commerce Connect 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.
Updated 15 days ago