Skip to content

Plugins & Observers

Extension points, event handling, and interception patterns in the Checkout module.

Extension Points Overview

1
Plugin Declaration
2
Plugin Classes
6
Observer Classes
1
Event Subscribed

Note: The Checkout module has minimal plugins/observers by design. Most checkout customization happens through layout XML, JavaScript components, and Payment/Shipping module extensions.

Plugin Declarations

di.xml Plugin Configuration

The Checkout module declares one plugin in its di.xml:

recollect_quote_on_customer_group_change

Target Class

Magento\Customer\Model\ResourceModel\Customer

Plugin Class

Magento\Checkout\Model\Plugin\RecollectQuoteOnCustomerGroupChange

Purpose

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.

Intercepted Method

afterSave()

When Triggered

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.

Plugin Classes (2)

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

Observer Classes (6)

The Checkout module has 6 observer classes, though only 1 is declared in events.xml. Others are used internally or via other modules.

SalesQuoteSaveAfterObserver

Declared in events.xml

Event Name

sales_quote_save_after

Observer Name

set_checkout_quote_id

Purpose

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.

Area

global

Disabled

No

Shared

Yes (default)

Other Observer Classes

Observer/

Directory contains 6 observer class files for various checkout events

Events Reference

Events Subscribed To

Event Name Observer Area Purpose
sales_quote_save_after SalesQuoteSaveAfterObserver global Sync session quote ID

Key Events to Hook Into

While Checkout module declares few events, these are the most useful events for checkout customization:

checkout_cart_add_product_complete

After product is added to cart

checkout_cart_update_items_after

After cart items are updated

checkout_onepage_controller_success_action

Order success page displayed

checkout_submit_all_after

After order submission (from Quote module)

Preference Declarations (14)

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

Extension Best Practices

Recommended Approaches

  • Use layout XML to add/modify checkout steps
  • Extend Knockout.js components via mixins
  • Implement custom payment/shipping methods via their respective modules
  • Use CustomerData sections for frontend state

Avoid

  • Overriding core checkout controllers
  • Direct session manipulation without using Session class
  • Bypassing rate limiter interfaces
  • Modifying quote directly instead of using management interfaces