0

I've tried all posts on this subject but couldn't make it work.

I need to retrieve customer email during checkout, just after he fills the address form, on select payment method page.

This info is not stored in session (it is only if customer is logged in).

I've checked the table "quote_address" in database as well. The column "email" is empty while "firstname", "lastname", "street" have data.

I've tried javascript with no success either.

Where is that email stored?

Can someone help me on this? If so, please provide detailed answer.

Thanks in advance.

0

I would use the model \Magento\Checkout\Model\Session

and then from this model, I would load the quote ($this->_checkoutSession->getQuote())

and then you can read the customer email that is in your delivery address using $quote->getCustomerEmail().

The link https://community.magento.com/t5/Magento-2-x-Programming/Uncaught-Error-Call-to-a-member-function-getQuote-on-null/td-p/92665 will show you how to get checkoutSession in your code

|improve this answer|||||
  • Thank you Herve for your answer. I've already tried that. getQuote() returns an array with no email when guest customer on confirm order page. If the customer is logged in or "has remember me" activated the email is visible. [base_grand_total] => 5.9200 [customer_tax_class_id] => 3 [customer_group_id] => 0 [customer_note_notify] => 1 [customer_is_guest] => 0 [remote_ip] => – Tz V Dec 19 '19 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.