BuyerActions versus BuyerActionDetails in calculator logic
Key Takeaway
BuyerActions tells a custom orchestrator what kind of thing happened. BuyerActionDetails, which a custom calculator gets with getOptionalBuyerActionDetails().get(), tells the calculator exactly what changed.
BuyerActions and BuyerActionDetails both describe what the buyer did to the cart since the last calculation run, but at different levels of detail. BuyerActions gives simple true/false answers, so a custom orchestrator can choose which calculators to run. BuyerActionDetails gives a custom calculator itemized lists of exactly what changed.
Three levels of control
The Cart Calculate API has three levels of control:
- Orchestrators control which calculators run and when.
- Calculators handle cart calculations, such as shipping and tax.
- Services handle specific calculations that can reach beyond the cart. For example, the Pricing service also affects product detail pages.
A custom orchestrator extends the CartExtension.CartCalculate class and is registered for the Commerce_Domain_Cart_Calculate extension point. The system calls it whenever cart calculations are needed, such as when a buyer adds a product to the cart.