Monday, 16 March 2015

Get latest order info for current user session in magento

Get latest order info for current user session
Task: Get latest order info for current user session
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$id = Mage::getSingleton('checkout/session')
->getLastRealOrderId();
$order = Mage::getSingleton('sales/order')
->loadByIncrementId($id);

if ($totalData = $order->getData()) {
 if (array_key_exists('subtotal', $totalData)) {
  $subtotal = $totalData['subtotal'];
 }
 if (array_key_exists('grand_total', $totalData)) {
  $grandTotal = $totalData['grand_total'];
 }
}

/* more available values in $totalData
 shipping_amount
 customer_id
 store_id
 is_active
 created_at
 updated_at
 shipping_amount
 tax_amount
 weight
 remote_ip => 10.33.49.19
 customer_email
 customer_prefix
 customer_firstname
 customer_lastname
 store_currency_code
 shipping_method
 shipping_description
 state
 status
 store_name
 customer_group_id
 billing_address_id
 shipping_address_id
 customer_dob
*/



No comments:

Post a Comment