How can I get all orders of a customer via his/her email id who is logged in,
I am using current session to get user's email id
public function getCustomerData() {
if ($this->_customerSession->isLoggedIn()) {
return $this->_customerSession->getCustomerData();
}
return false;
}
In phtml
$customerData = $block->getCustomerData();
if($customerData) {
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>'; }
Earlier I was getting my orders information by order id
public function getOrderInformation($orderid)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\OrderRepositoryInterface')->get($orderid);
return $order;
}
How can I get all orders by customer email id
Best Answer
I hope this will help