在Magento中获取订单增量ID

在Magento中获取订单增量ID

本文介绍了在Magento中获取订单增量ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在success.phtml页面上获取Magento中的订单增量ID,以便可以将其用于会员跟踪.

I'm trying to get the Order Increment Id in Magento, on the success.phtml page so that I can use this for affiliate tracking.

我正在使用以下代码,但第二行给出了错误;

I'm using the following code, but it is giving an error on the second line;

$order = Mage::getSingleton('sales/order')->getLastOrderId();
$lastOrderId = $order->getIncrementId();

该错误显示为:

我想知道是否有人对如何获得订单增量ID有任何想法?这是在管理员中看到的参考号,通常类似于:#1000123

I was wondering if anyone has any ideas on how to get the Order Increment Id? This is the reference number seen in the admin, usually something like: #1000123

推荐答案

如果您是在结帐成功页面上专门进行此操作-在success.phtml中-则模板中已经提供了用于获取订单增量ID的代码,因为它已显示给客户.

If you're specifically doing this on the checkout success page - in success.phtml - then the code to get the order increment ID is already available in the template, since it is displayed to the customer.

您只需要以下内容:

$orderId = $this->getOrderId();

请注意,这在其他页面上将不起作用,因此,对于这些页面,您需要使用:

Note that this won't work on other pages so, for those, you'd need to use:

$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();

这篇关于在Magento中获取订单增量ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:37