Cert++
Close

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.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Troubleshoot the B2B Commerce system using available tools

0/22

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers. 757 members and growing.