問題描述
我正在嘗試在 Magento 中的 success.phtml 頁面上獲取訂單增量 ID,以便我可以將其用于會(huì)員跟蹤.
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.
我正在使用以下代碼,但在第二行出現(xiàn)錯(cuò)誤;
I'm using the following code, but it is giving an error on the second line;
錯(cuò)誤如下:
致命錯(cuò)誤:在第 34 行調(diào)用非對象上的成員函數(shù) getIncrementId():$LastOrderId = $order->getIncrementId();
Fatal error: Call to a member function getIncrementId() on a non-object on line 34: $LastOrderId = $order->getIncrementId();
我想知道是否有人對如何獲取訂單增量 ID 有任何想法?這是在管理員中看到的參考編號(hào),通常類似于:#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
推薦答案
如果您專門在結(jié)帳成功頁面上執(zhí)行此操作 - 在 success.phtml 中 - 那么獲取訂單增量 ID 的代碼已在模板中可用, 因?yàn)樗秋@示給客戶的.
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.
您只需要以下內(nèi)容:
請注意,這不適用于其他頁面,因此,對于那些頁面,您需要使用:
Note that this won't work on other pages so, for those, you'd need to use:
這篇關(guān)于在 Magento 中獲取訂單增量 ID的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!