Magento Questions 获取客户详细信息,onepage/checkout/success 不发送电子邮件

发布于 2024-11-08 21:36:17 字数 1434 浏览 0 评论 0原文

如何获取客户数据,以便我可以将其传递给网关支付。

这是我的模型:

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;
    }

这是我的控制器:

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)。当客户重定向至此处时,不会向客户发送电子邮件,并且订单不会更新为已完成。

How to get customers data so i can pass it to a gateway payment.

Here is my model:

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;
    }

here is my 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();
    }

This are running perfectly running, the problem is i can't get customer details such as customer name, address and etc.

I already tried this code

Mage::getSingleton(customer/customer)->getData();

There was a result but not printing.

In the checkout page success (onepage). When customer redirected here, There is no email will be send to the customer and the order was not update as completed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丑丑阿 2024-11-15 21:36:17

您正在尝试加载具有属于该订单的 ID 的客户。这显然行不通!您需要从订单中提取 customer_id 并基于此加载客户模型。

$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());

您还使用了 Mage::getSingleton 这是错误的调用。您需要一个针对特定客户定制的新实例,而不是该类的单个允许实例。

You're trying to load a customer with an id that belongs to the order. This obviously doesn't work! You need to extract the customer_id from the order and load the customer model based on that.

$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());

You're also using Mage::getSingleton which is the wrong call. You want a new instance tailored to a specific customer, not the single permissible instance of the class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文