Work with Events in an Extension
In the Extensibility API, events correspond to operations that occur in the following components:
-
ProductListPageComponent
-
ProductDetailsComponent
-
CartComponent and BackendCartComponent
-
CheckoutComponent
Each operation triggers two events: an event that occurs before the operation starts and an event that occurs after the operation completes. You can subscribe to these events and then direct an extension to act on the results of the operation. Each component includes listeners that inherit from the CancelableEvents
class; if you subscribe to the before
event, you can cancel the operation.
Events can trigger due to user action or another process programmatically triggering the event. For example, if a user adds an item to the cart or an extension calls the CartComponent.addLine(line)
method , both the beforeAddLine
and afterAddLine
events trigger. However, if you cancel the operation, the afterAddLine
event does not occur.
The following lists the events for each component:
ProductListPageComponent
beforeOptionSelection
afterOptionSelection
beforeQuantityChange
afterQuantityChange
beforeImageChange
afterImageChange
ProductDetailsComponent
beforeOptionSelection
afterOptionSelection
beforeQuantityChange
afterQuantityChange
beforeImageChange
afterImageChange
CartComponent
afterAddLine
beforeAddLine
afterAddPayment
beforeAddPayment
afterAddPromotion
beforeAddPromotion
afterClearEstimateShipping
beforeClearEstimateShipping
afterEstimateShipping
beforeEstimateShipping
afterRemoveLine
beforeRemoveLine
afterRemovePromotion
beforeRemovePromotion
afterSubmit
beforeSubmit
afterUpdateLine
beforeUpdateLine
BackendCartComponent
afterAddLine
beforeAddLine
afterAddPayment
beforeAddPayment
afterAddPromotion
beforeAddPromotion
afterClearEstimateShipping
beforeClearEstimateShipping
afterEstimateShipping
beforeEstimateShipping
afterRemoveLine
beforeRemoveLine
afterRemovePromotion
beforeRemovePromotion
afterSubmit
beforeSubmit
afterUpdateLine
beforeUpdateLine
CheckoutComponent
afterAddModuleToStep
beforeAddModuleToStep
afterAddStep
beforeAddStep
afterAddStepsGroup
beforeAddStepsGroup
afterSetCurrentStep
beforeSetCurrentStep