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?
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:
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+IOrderFormCalculatormanually?Or some end-to-end “checkout pipeline” pattern?
Looking for guidance on a clean, production-safe approach.
Thanks,
Sunil