如何获取客户数据以便将其传递给支付网关。
这是我的模型:
public function getStandardCheckoutFormFields() {
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
//$order = $this->get_sale_order($orderIncrementId);
echo Mage::getModel('customer/customer')->load($orderIncrementId);
$productArray = array();
foreach ($order->getAllItems() as $item) {
$productArray[] = array(
"product_name" => $item->getName(),
"product_qty" => $item->getQtyOrdered(),
"product_price" => $item->getPrice(),
);
}
return $productArray;
}
这是我的 Controller :
public function redirectAction(){
$session = Mage::getSingleton('checkout/session');
$session->setAsurepayCustompayQuoteId($session->getQuoteId());
$this->getResponse()->setBody($this->getLayout()->createBlock('custompay/redirect')->toHtml());
$session->unsQuoteId();
$session->unsRedirectUrl();
}
运行正常,问题是我无法获取客户详细信息,例如客户姓名、地址等。
我已经试过这段代码
Mage::getSingleton(customer/customer)->getData();
有结果但不打印
在结帐页面成功(onepage)。当客户重定向到此处时,不会向客户发送任何电子邮件,订单也不会更新为已完成。
最佳答案
您正在尝试使用属于订单的 ID 加载客户。这显然行不通!您需要从订单中提取 customer_id
并基于它加载客户模型。
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
您还使用了 Mage::getSingleton
,这是错误的调用。您想要一个为特定客户量身定制的新实例,而不是该类的单个允许实例。
关于php - Magento Questions 获取客户详细信息并且 onepage/checkout/success 不发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6075464/