【问题标题】:Magento Get Last Order Id on Payment Info Block EmailMagento 在付款信息块电子邮件中获取最后一个订单 ID
【发布时间】:2012-03-02 21:01:02
【问题描述】:

见上图是 Magento 的新订单确认邮件。 在我们正在开发的网站上,我们使用 Fontis 澳大利亚扩展 (http://www.magentocommerce.com/magento-connect/fontis-australia.html) 来实施 BPay 支付方式。扩展工作正常,除了在订单确认电子邮件上,电子邮件参考总是显示 000000。

我尝试查看它,发现生成的参考编号需要订单 ID 作为输入才能生成正确的参考编号。 扩展程序使用此代码获取付款信息​​块上的最后一个订单号: $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();

我尝试使用并打印来自其他控制器的结果,它显示了正确的订单号。但似乎对于电子邮件上的付款信息块,无法检索订单号信息。实际上结帐成功页面上也调用了相同的块,并且显示正确。

有人可以建议其他方法来获取 Magento 电子邮件付款信息块上的最后一个订单 ID 吗?

【问题讨论】:

    标签: email magento block payment


    【解决方案1】:

    在信息模板中,您可以使用$order = $this->getInfo()->getOrder(); 获取Mage_Sales_Model_Order 对象。然后你可以通过$order->getData('increment_id')获取当前订单id。

    但是使用此代码,您会在结帐过程中出错,因为$this->getInfo() 返回其他模型。

    所以 dirty 解决方案对我来说没有错误,是:

    $info = $this->getInfo();   
    if ($info instanceof Mage_Sales_Model_Order_Payment) {
        $order = $info->getOrder();
        echo $order->getData('increment_id'));
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 2014-07-10
      • 2016-03-17
      相关资源
      最近更新 更多