Helper/Helper.php
public function prepareGuestQuote($quote, $email = null) {
        // Retrieve the user email 
        $guestEmail = $email
        ?? $this->customerSession->getData('checkoutSessionData')['customerEmail']
        ?? $quote->getCustomerEmail() 
        ?? $quote->getBillingAddress()->getEmail()
        ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME);

        // Set the quote as guest
        $quote->setCustomerId(null)
        ->setCustomerEmail($guestEmail)
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID);

        // Delete the cookie
        $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME);

        return $quote;
    }
public function prepareGuestQuote($quote, $email = null) {
        // Retrieve the user email 
        $guestEmail = $email
        ?? $this->customerSession->getData('checkoutSessionData')['customerEmail']
        ?? $quote->getCustomerEmail() 
        ?? $quote->getBillingAddress()->getEmail()
        ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME);

        // Set the quote as guest
        $quote->setCustomerId(null)
        ->setCustomerEmail($guestEmail)
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID);

        // Delete the cookie
        $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME);

        return $quote;
    }
public function prepareGuestQuote ( $ quote , $ email = null ) { // Retrieve the user email  $ guestEmail = $ email ?? $ this -> customerSession -> getData ( 'checkoutSessionData' ) [ 'customerEmail' ] ?? $ quote -> getCustomerEmail ( ) ?? $ quote -> getBillingAddress ( ) -> getEmail ( ) ?? $ this -> cookieManager -> getCookie ( self :: EMAIL_COOKIE_NAME ) ; // Set the quote as guest $ quote -> setCustomerId ( null ) -> setCustomerEmail ( $ guestEmail ) -> setCustomerIsGuest ( true ) -> setCustomerGroupId ( GroupInterface :: NOT_LOGGED_IN_ID ) ; // Delete the cookie $ this -> cookieManager -> deleteCookie ( self :: EMAIL_COOKIE_NAME ) ; return $ quote ; }
Sets the email for guest users

@return bool
Sets the email for guest users