What is the correct structure to load the email of the customer from? It should work in all order variants: orders by guests, orders by registrered customers, already saved addresses, newly entered addresses in checkout process.
Background: I'm investigating an issue with a payment extension. I turned out that sometimes the extension doesn't have an email address for the customer.
We found that the extension loads the email address for order processing the following way:
Testing in stock magento 18.104.22.168 with sample data showed that the email address is not saved into the billing address if
- customer creates an account (just name, email, password, no addresses)
- customer loads cart and starts checkout with entering billing/shipping address.
In this case billing/shipping address don't have email set and the extension fails. You can confirm this by looking at the tables
There are more places to load the email from:
$order->getCustomer()->getEmail() $order->getCustomerEmail() $quote->getCustomerEmail()
So what is the correct structure to load the email from?