Magento – Get customer details in backend admin panel order

adminhtmlcustomersales-order

What I have done:

I have few custom calculations to be done after placing an order for the customer in magento admin panel. I have hooked on to sales_order_save_after event inside tab inside my module's config.xml .

The Problem:

I need to get the customer_id of the actual customer for whom the order is been placed on the backend. How can this be done?

$_customer = Mage::getSingleton('customer/session')->getCustomer();
$customer_id=$_customer->getId(); 

The above will give me the customer_id in case of front end, I need a way to get the customer's id when ordering from backend.

In case, the event "adminhtml_sales_order_create_process_data", is what I need to hook on, do let me know. because I am also kind of confused about which event to hook on.

Help me out.

Best Answer

If your order already placed from admin - admin might have selected a customer or created using direct customer details.

If the order was placed from frontend then the order object will be having customer details.

By an case you will able to retrieve customer details of an order using

 $_order->getCustomer() 

From this you will able to retrieve all details of that order's customer(If they were logged in)

Related Topic