helper = $data; $this->quoteResource = $quoteResource; $this->checkoutSession = $session; parent::__construct($context); } /** * Easy email capture for Newsletter and Checkout. * * @return null */ public function execute() { $email = $this->getRequest()->getParam('email'); if ($email && $quote = $this->checkoutSession->getQuote()) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return null; } if ($quote->hasItems()) { try { $quote->setCustomerEmail($email); $this->quoteResource->save($quote); } catch (\Exception $e) { $this->helper->debug((string)$e, []); } } } } }