Calculate orders
Describes the components involved when calculating orders in Optimizely Commerce Connect.
The following calculation services are available to calculate order totals at different levels:
- Line item calculator – Calculates extended price, discounted price, line item price, and sales tax for an item.
- Shipping calculator – Calculates shipping cost, shipping taxes, and total amount for items in a shipment.
- Tax calculator – Calculates taxes based on tax value and retrieves tax values.
- 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 a return item.
- Return order form calculator – Calculates totals, discount total, and tax total on a return order form.
- Return purchase order calculator – Calculates totals and discount total on a return purchase order.
Improvements to calculator behavior
Starting in Commerce Connect 12, the order calculation functionality was improved as follows:
- Avoid unnecessary recalculations – Previously, calculators recalculated prices and taxes even if an order had no changes, or if the changes did not affect results. This was inefficient, especially when using an external tax service, and it caused problems with stale data, such as old orders, deleted products, and expired or newly added promotions. In Commerce Connect 12, if an order has no changes that affect results, no recalculation occurs. Instead, the previously calculated values are returned.
TaxCategoryIdproperty onLineItem– A newTaxCategoryIdproperty onLineItemstores the tax category for the line item. As a result, Commerce Connect retains tax information for later order processing even if the product is deleted.- Store results on relevant objects – In Commerce Connect 12, when a calculation requires expensive work, such as calling an external tax service or reading from a database, the result is stored on the relevant object. If any of the following properties change, the result is recalculated and saved with the corresponding object.
OrderGrouporSerializableCart(calculates tax total)MarketIdCurrencyCode
ShipmentorSerializableShipment(calculates shipping tax and shipping cost)ShippingMethodIdShippingAddressLineItems(adding or removing a line item)ShipmentDiscount
LineItemorSerializableLineItem(calculates sales tax)PlacedPriceQuantityOrderAmountEntryAmountTaxCategoryId
Shipment is required for correct calculation
When you create an order (cart, purchase order, or payment plan) through IOrderRepository, a shipment is created automatically. Order calculators only calculate line items that belong to a shipment — this is a change from the prior workflow-activity behavior.
Updated 21 days ago
