Custom calculator price fields and $NaN order summary amounts
Key Takeaway
$NaN on a line item that should show $0.00 most likely means a custom price or promotion calculator left a price field null or undefined. Fix the calculator so it explicitly sets the field to 0.
In B2B Commerce, a developer can replace the default pricing and promotion logic in cart and checkout with custom Apex calculators. If a custom calculator leaves a price field null or undefined instead of setting it to 0, the order summary can show $NaN on line items that should show $0.00. The fix belongs in the calculator code, so that is where you troubleshoot.
Orchestrators and calculators
In the Cart Calculate API, orchestrators decide which calculators run and when. Calculators do the actual calculations.
The orchestrator's prices() and promotions() methods call your custom Apex calculator if you supplied one. They call the default calculator only when you did not, so a custom calculator runs in place of the default one.
The prices() and promotions() methods on CartExtension.CartCalculate cannot be overridden. To change price or promotion logic, supply a custom PricingCartCalculator or PromotionsCartCalculator. A custom orchestrator overrides calculate() instead. Inside that override, it can call super.calculate() to reach the base implementation.