7

I have a controller that load order like this:

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);

Is there a way to get a customer e-mail address by load order by id like this?

1

2 Answers 2

17

Try this :

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);
$email = $order->getCustomerEmail();

To get Customer Id :

$customerId = $order->getCustomerId();
2
  • You should use DI for that instead of using the object manager directly Jul 14, 2017 at 15:13
  • You can inject Order Class Model in your controller __construct method and call in execute method. Jan 28, 2020 at 16:49
2

Get Customer Id from order details and load your customer and you can get Customer Email.

UPDATE:

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);

$customerId = $order->getCustomerId();

1
  • how to get the customer id and then the customer email?
    – simple guy
    Feb 2, 2017 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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