Surfacing calculation errors with CartValidationOutput
Key Takeaway
When a custom cart extension fails, make sure it creates a CartValidationOutput. By default, buyers see the message only when its Level is Error and its Type is Inventory, Pricing, Promotions, or Entitlement.
CartValidationOutput is the record a B2B Commerce or D2C Commerce cart uses to hold errors, warnings, and info messages, such as "Out of stock". Each message is tied to the cart itself or to a specific cart item, delivery group, or tax. Custom cart extensions create these outputs when a calculation fails, so the problem can be shown and handled instead of leaving checkout stuck.
Why a failed extension needs an output
Make sure every custom extension (Tax, Inventory, Pricing, Promotions, Shipping) creates a CartValidationOutput record whenever it fails. A custom extension that fails without creating one is a common misconfiguration. Checkout then stays in an inconsistent or blocked state. The error is also hard to surface or handle.