Trigger Proceed to checkout button in Magento 2

Here you need to build a module in which you need to use event ‘controller_action_predispatch_checkout_index_index’.

Create registration.php Create events.xml under etc/frontend directory

Create CheckShoppingCartObserver.php file under Observer directory.


namespace Module\Customize\Observer;

use Magento\Framework\Event\ObserverInterface;

class CheckShoppingCartObserver implements ObserverInterface
{
protected $_request;

public function __construct(\Magento\Framework\App\RequestInterface $request)
{
    $this->_request = $request;
}

/**
 *
 * @param \Magento\Framework\Event\Observer $observer
 * @return void
 */
public function execute(\Magento\Framework\Event\Observer $observer)
{
   $quote = $observer->getQuote();
    $order = $observer->getOrder();
    $quoteItems = [];

    // Map Quote Item with Quote Item Id
    foreach ($quote->getAllVisibleItems() as $quoteItem) {
        $quoteItems[$quoteItem->getId()] = $quoteItem;
    }
    // write your code according to 

Leave a comment

Your email address will not be published. Required fields are marked *