简体   繁体   English

在后端管理面板订单中获取客户详细信息

[英]Get customer details in backend admin panel order

What I have done: 我做了什么:

I have few custom calculations to be done after placing an order for the customer in magento admin panel. 在magento管理面板中为客户下订单后,我需要执行的自定义计算很少。 I have hooked on to sales_order_save_after event inside tab inside my module's config.xml . 我已经迷上了模块config.xml中选项卡内的sales_order_save_after事件。

The Problem: 问题:

I need to get the customer_id of the actual customer for whom the order is been placed on the backend. 我需要获取在后台下订单的实际客户的customer_id。 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. 上面将在前端情况下给我customer_id,我需要一种从后端订购时获取客户ID的方法。

In case, the event "adminhtml_sales_order_create_process_data", is what I need to hook on, do let me know. 万一事件“ adminhtml_sales_order_create_process_data”是我需要关注的,请告诉我。 because I am also kind of confused about which event to hook on. 因为我也对要挂接的事件感到困惑。

Help me out. 帮帮我。

Please use this event sales_order_place_after . 请使用此事件sales_order_place_after And in your code, you might get the customer id like this: 在您的代码中,您可能会获得如下的客户ID:

public function hookSalesOrderPlaceAfter(Varien_Event_Observer $observer) {
   $order = $observer->getEvent()->getOrder();
   $customer_email = $order->getCustomerEmail();
   $website_id = Mage::app()->getStore()->getWebsiteId();
   $customer = Mage::getModel('customer/customer')->setWebsiteId($website_id)->loadByEmail($customer_email);
   ...
}

Hope it will help you. 希望对您有帮助。

This code below works for me (Thanks to Makwana Ketan shared this code) 以下代码对我有用 (感谢Makwana Ketan共享了此代码)

  $sessionquoteId = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getId();
    $sessionCustomerId = Mage::getModel('sales/quote')->loadByIdWithoutStore($sessionquoteId)->getCustomerId();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM