Plugins & Observers
Extension points, event handling, and interception patterns in the Checkout module.
Extension points, event handling, and interception patterns in the Checkout module.
Note: The Checkout module has minimal plugins/observers by design. Most checkout customization happens through layout XML, JavaScript components, and Payment/Shipping module extensions.
The Checkout module declares one plugin in its di.xml:
Magento\Customer\Model\ResourceModel\Customer
Magento\Checkout\Model\Plugin\RecollectQuoteOnCustomerGroupChange
When a customer's group is changed (e.g., from General to Wholesale), this plugin triggers quote recollection to update pricing based on the new customer group's catalog price rules and tier pricing.
afterSave()
Customer entity save with group_id change
Business Logic
If the customer has an active quote and their customer group has changed, the plugin
sets trigger_recollect = 1 on the quote, forcing
totals recalculation on the next checkout interaction.
The Checkout module contains 2 plugin classes in the Plugin directory:
| Plugin Class | Target | Purpose |
|---|---|---|
| RecollectQuoteOnCustomerGroupChange | Customer ResourceModel | Trigger quote recollect on customer group change |
| Model\Plugin\* | Various | Additional plugin implementations |
The Checkout module has 6 observer classes, though only 1 is declared in events.xml. Others are used internally or via other modules.
Declared in events.xml
sales_quote_save_after
set_checkout_quote_id
Synchronizes the checkout session's quote ID with the saved quote. This ensures the session always references the correct quote after any quote save operation.
global
No
Yes (default)
Directory contains 6 observer class files for various checkout events
| Event Name | Observer | Area | Purpose |
|---|---|---|---|
| sales_quote_save_after | SalesQuoteSaveAfterObserver | global | Sync session quote ID |
While Checkout module declares few events, these are the most useful events for checkout customization:
After product is added to cart
After cart items are updated
Order success page displayed
After order submission (from Quote module)
The Checkout module declares 14 preferences in di.xml, mapping interfaces to implementations:
| Interface | Implementation |
|---|---|
| GuestShippingInformationManagementInterface | GuestShippingInformationManagement |
| ShippingInformationManagementInterface | ShippingInformationManagement |
| Data\ShippingInformationInterface | Model\ShippingInformation |
| Data\PaymentDetailsInterface | Model\PaymentDetails |
| GuestPaymentInformationManagementInterface | GuestPaymentInformationManagement |
| PaymentInformationManagementInterface | PaymentInformationManagement |
| Data\TotalsInformationInterface | Model\TotalsInformation |
| GuestTotalsInformationManagementInterface | GuestTotalsInformationManagement |
| TotalsInformationManagementInterface | TotalsInformationManagement |
| AgreementsValidatorInterface | AgreementsValidator |
| Cart\RequestInfoFilterInterface | Cart\RequestInfoFilterComposite |
| AddressComparatorInterface | AddressComparator |
| PaymentProcessingRateLimiterInterface | CaptchaPaymentProcessingRateLimiter |
| PaymentSavingRateLimiterInterface | CaptchaPaymentSavingRateLimiter |