Magento 在 success.phtml 上从 guest 获取数据
我正在尝试在结帐成功页面上获取小计金额。它对于注册用户来说效果很好:
$_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$amount = $_order->getData('subtotal');
$total = number_format($amount, 2);
但是当订单由访客处理时,$total
为空。
可以做什么?
PS:我正在使用Magento 1.6.1 CE
I am trying to get the subtotal amount on checkout success page. It works good for registred users:
$_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$amount = $_order->getData('subtotal');
$total = number_format($amount, 2);
But when the order is processed by a guest, $total
is empty.
What can be done?
P.S.: I am using Magento 1.6.1 CE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
摘自 Magento 的
app/code/core/Mage/Checkout/Block/Onepage.php
:我 99% 确信您可以使用
getOrder()
执行完全相同的操作Mage_Checkout_Block_Success
=)注意:
isCustomerLoggedIn()
方法定义于Mage_Checkout_Block_Onepage_Abstract
不被Mage_Checkout_Block_Success
继承。因此,您可以简单地使用它的实现:例如,您的代码现在应如下所示:
抱歉之前说了无意义的事情......
Taken from Magento's
app/code/core/Mage/Checkout/Block/Onepage.php
:I am 99% sure you can do exactly the same with
getOrder()
and withMage_Checkout_Block_Success
=)Note: the
isCustomerLoggedIn()
method is defined atMage_Checkout_Block_Onepage_Abstract
which is not inherited byMage_Checkout_Block_Success
. So, you could simply use its implementation:E.g. your code now shall look like this:
Sorry for saying non-sense things before...