Magento failure.phtml,获取订单总数
我从事的项目之一在 magento 中的失败页面和成功页面完全相同,并且需要在这两个页面上添加一些跟踪代码。跟踪代码需要订单 ID 和订购金额。我遇到的问题是尝试在失败页面上获取订单总数。
块类 Mage_Checkout_Block_Onepage_Failure
内置的方法是 getRealOrderId()
、getErrorMessage()
和 getContinueShoppingUrl()
,因此那里没有帮助。
我找到了一些代码可以在成功页面上执行我想要的操作,但它不适用于失败页面。
<?php
$orderId = $this->getRealOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($orderId);
$_totalData = $order->getData();
$_grand = $_totalData['grand_total'];
?>
我转储了 $order
和 $_totalData
。 $_totalData
只是一个空数组,而 $order
是一个空的 Mage_Sales_Model_Order
实例。
有人对哪里可以获得所购买商品的总计有任何建议吗?
问候, Kieran
(我在测试成功页面时也遇到问题,因为我无法访问它,甚至在开发服务器上输入正确的测试卡详细信息 - 但我会找到解决此问题的方法)
One of the projects I work on has the failure page and success page in magento as exactly the same and requires some tracking code on both. The tracking code requires the order ID and the amount being ordered. The issue I'm having is trying to get the order total on the failure page.
The methods built into the block class Mage_Checkout_Block_Onepage_Failure
are getRealOrderId()
, getErrorMessage()
and getContinueShoppingUrl()
, so no help there.
I found some code to do what I want on the success page but it doesn't work for the failure page.
<?php
$orderId = $this->getRealOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($orderId);
$_totalData = $order->getData();
$_grand = $_totalData['grand_total'];
?>
I dumped $order
and $_totalData
. $_totalData
just an empty array and $order
an empty Mage_Sales_Model_Order
instance.
Does anyone have any suggestions for where to get the grand total of what is being purchased?
Regards,
Kieran
(I'm also having issues testing the success page as I can't get to it, even putting in the correct test card details on the dev server - but I'll find a way around this)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果订单失败,则没有订单可使用,这似乎是明智的。
也许,购物车还没有被清空,在这种情况下,您可以使用以下命令获取活动总计
If the order failed then there is no order to use, that seems sensible.
Perhaps, also, the cart hasn't been emptied in which case you can get the active totals with