5.4.1: Introduction

5.4: Totals


Many separate total amounts must be tracked on quotes and orders: not only individual line item prices, subtotal, and grand total, but also tax, discounts, shipping, etc. The calculation of these totals can be complex, and often totals are interdependent. Rather than attempt to make granular changes to totals in response to actions (for example, just updating a line item total, subtotal and grand total when quantity is changed on an item), Magento encapsulates the entire "collect totals" process in an operation that can be performed at any time to recalculate and "refresh" all totals from the current state of a quote. A dedicated model for each total encapsulates its calculation logic, and these are invoked in an appropriate sequence.

Customization scenarios for totals in the cart/order process are frequent, so understanding totals collection is critical.

We'll discuss three topics in this section:

  • The totals calculation process at a high level
  • Individual total collectors
  • The totals rendering process
Complete and Continue