Monday, 16 March 2015

Get Last Order Customer Details in magneto

Get Last Order Customer Details in magneto
Magento Offers a very basic “THANK YOU PAGE”. In major E-commerce website they provide a “THANK YOU PAGE” with all order details and summary.
We had the same requirement for our customer. I created a Thank You page with all Order Summary and Order Details in Magento.
I’ll try to cover this up in two posts.
Goto : app/design/frontend/YOURTHEME/default/template/checkout/success.phtml
Part – I : How to bring the Order Summary
I’ll Try to explain the code when necessary, First we will cover the code for Order Summary

Foremost, We need to create the object for Order placed. Create it using
$orderObj = Mage::getModel(‘sales/order’)->loadByIncrementId($this->getOrderId());
Get the object of the Last Order Placed
$lastOrder = Mage::getModel(‘sales/order’)->load(Mage::getSingleton(‘checkout/session’)->getLastOrderId());
From the Last Order Object, billing and shipping address can be obtained. Use following code for it.
$billingAddress = $lastOrder->getBillingAddress();
$shippingAddress = $lastOrder->getShippingAddress();
Suppose, You want to get the detailed Shipping Information use the following code for it.
echo $shippingAddress['firstname']
echo $shippingAddress['lastname']
echo $shippingAddress['street']
echo $shippingAddress['city']
echo $shippingAddress['region']
echo $shippingAddress['postcode']
echo $shippingAddress['country_id']
To Get the Date of the Order, use following code
echo $orderObj->getCreatedAtStoreDate();
To Get the Grand Total use following Code
echo $orderObj->getGrandTotal();



No comments:

Post a Comment