Skip to content

Checkout Emit Messages

When a customer is going through the checkout process, a number of messages are emitted. Custom components (and JavaScript) can listen to them and re-render if needed.

Shipping Address emit messages

Shipping Address added

  • shipping_address_added
  • guest_shipping_address_added
  • customer_shipping_address_added

Shipping Address submitted

  • shipping_address_submitted
  • guest_shipping_address_submitted
  • customer_shipping_address_submitted

Shipping Address saved

  • shipping_address_saved
  • guest_shipping_address_saved
  • customer_shipping_address_saved

Shipping Address selected

  • shipping_address_activated

Billing Address emit messages

Billing Address added

  • billing_address_added
  • guest_billing_address_added
  • customer_billing_address_added

Billing Address submitted

  • billing_address_submitted
  • guest_billing_address_submitted
  • customer_billing_address_submitted

Billing Address saved

  • billing_address_saved
  • guest_billing_address_saved
  • customer_billing_address_saved

Billing Address selected

  • billing_address_activated

Coupon emit messages

  • coupon_code_applied
  • coupon_code_revoked

Payment Method emit messages

  • payment_method_selected

Shipping Method emit messages

  • shipping_method_selected

Updating Component Listeners

Thanks to the Magewire Event trait, every component has a simple way to define a list of event listeners - using the $listeners property. As an integrator, you may find yourself in the situation where you would like to modify the list of Magewire events that a component listens for - whether that be to add a new listener, remove an existing listener, invoke a different function when observing an event, or something else. Thankfully the aforementioned Magewire Event trait also provides a convenient getListeners() function so these sorts of customisations are easy to implement using the Magento plugin system.

Examples

Customising a component's event listeners involves two easy steps:

  1. Define a plugin for the component you want to modify in etc/frontend/di.xml
  2. Implement the customisation logic in your plugin class
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Hyva\Checkout\Magewire\Checkout\Foo">
        <plugin name="update_hyva_checkout_foo_component_listeners"
                type="Vendor\Module\Plugin\UpdateFooListeners"/>
    </type>
</config>
<?php
declare(strict_types=1);

namespace Vendor\Module\Plugin;

class UpdateFooListeners
{
    public function afterGetListeners(
        \Hyva\Checkout\Magewire\Checkout\Foo $subject,
        array $listeners
    ): array {
        // adding a new listener
        $listeners['foo'] = 'refresh';

        // removing a listener
        unset($listeners['bar']);

        // updating a listener
        $listeners['baz'] = 'someOtherFunction';

        return $listeners;
    }
}