Take the community feedback survey now.

How to safely force full order recalculation before saving a PurchaseOrder?

Vote:
 

Hi,

I’m working on a checkout flow in Commerce 14 where I need the order to be fully recalculated (prices, discounts, taxes, fees, shipping) right before the cart is converted into a PurchaseOrder.

Right now, I’m doing something like this:

var validation = _cartService.ValidateCart(cart);

if (!validation.IsSuccessful)
{
    // Handle errors
}

var purchaseOrder = _orderRepository.SaveAsPurchaseOrder(cart);
_orderRepository.Save(purchaseOrder);

It works most of the time, but I’ve noticed a few edge cases:

  • If inventory changes during checkout

  • If shipping address changes

  • If customer-specific pricing is applied

  • If promotions expire in between steps

…the totals on the final PurchaseOrder are sometimes slightly different from what the customer saw in the cart, and right now I am just showing payment sums not matched Error message on Website.

Is there a recommended way to force a full recalculation (pricing + taxes + promotions + shipping) right before SaveAsPurchaseOrder, with guaranteed consistency?

Should I be using:

  • ICartPipeline.Run(...)?

  • ICartService.RecalculateShipment(...)?

  • ILineItemCalculator + IOrderFormCalculator manually?

  • Or some end-to-end “checkout pipeline” pattern?

Looking for guidance on a clean, production-safe approach.

 

Thanks,

Sunil

 

#341134
Nov 28, 2025 10:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.