Controller/Ajax/Emailcapture.php
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, []);
                }
            }
        }
    }
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, []);
                }
            }
        }
    }
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 , [ ] ) ; } } } }
Easy email capture for Newsletter and Checkout.

@return null
Easy email capture for Newsletter and Checkout .