Magento2 Checkout Event-Observer – Is There an Observable Event for When the Checkout Begins in Magento 2

checkoutevent-observermagento2

when the checkout is started I need to modify the quote.

Is there an event when the checkout is started?

Thanks in Advance!

Best Answer

You need to use controller_action_predispatch_checkout_onepage_index observer

create app/code/Vendor/Module/etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
   <event name="controller_action_predispatch_checkout_onepage_index">
       <observer name="vendor_module_observer_checkoutinit" instance="Vendor\Module\Observer\Checkoutinit" />
   </event>
</config>

and create observer in app/code/Vendor/Module/Observer/Checkoutinit.php

class Checkoutinit implements \Magento\Framework\Event\ObserverInterface
{
  public function execute(\Magento\Framework\Event\Observer $observer)
  {
     //$order= $observer->getData('order');
     //$order->doSomething();

     return $this;
  }
}
Related Topic