Get last order of an customer magento

Comments Off on Get last order of an customer magento

magentoHere is the example code by which you can get last order details into mangento of using email id.

$_customer = Mage::getModel('customer/customer');
$_customer->loadByEmail('demo@demo.com');

$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', $_customer->getId())
->addAttributeToSort('created_at', 'DESC')
->setPageSize(1);

<strong>ID</strong>
echo $orders->getFirstItem()->getId();

Shashi Dhar Kumar Experience in Web/software development including client server and implementation using PHP, XML, MySQL and SQL Server. Experience of working on Apache, Linux projects, Javascript, Ajax, Putty, FTP, Remote Connection, XML parsing, Mod-Rewriting, Payment Gateways and shipping modules, Trouble shooting and Manual Testing.