如何在Magento Checkout Success.phtml 1.7上提取客户电子邮件

如何在Magento Checkout Success.phtml 1.7上提取客户电子邮件,magento,magento-1.7,Magento,Magento 1.7,我在网上尝试过各种各样的解决方案,但都无济于事。我认为应该是这样的: <?php $order->getBillingAddress()->getEmail(); ?> An email confirmation was sent to: <?php echo $order->getEmail ?> 已将电子邮件确认发送至: 我可以通过以下方式显示订单ID: <?php echo $this->getOrderId() ?>

我在网上尝试过各种各样的解决方案,但都无济于事。我认为应该是这样的:

<?php
$order->getBillingAddress()->getEmail();
?>

An email confirmation was sent to: <?php echo $order->getEmail ?>

已将电子邮件确认发送至:
我可以通过以下方式显示订单ID:

<?php echo $this->getOrderId() ?>


如果您有什么建议,请尽量具体,因为我绝对是新手。

尝试将此添加到Success.phtml中

<?php
   $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
   echo $order->getCustomerEmail();
?>

阅读更多信息:

尝试使用此代码

$_customerId = Mage::getSingleton('customer/session')->getCustomerId();

$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();

$order = Mage::getSingleton('sales/order'); 

$order->load($lastOrderId);
那就做吧

foreach($order as $_order){
    echo $_order->getCustomerEmail();
}

希望这有帮助

我试过那条线。可能我没有正确显示变量:请尝试上面的新代码。。。我正在按订单id加载订单,但它在成功页面上显示的id是订单增量id。此操作成功!我把第二行放在我需要它的文件中,并填充了电子邮件地址。谢谢。你能把我上面的答案标记为解决方案吗?这样每个人都会知道它是解决方案,而不是花时间去解决它。这会阻止代码执行。这可能是我实现表单中的最后一行:上面的代码将不起作用,因为当您使用->load()时,它将返回1条记录/对象(每个id一条记录),因此当它不是对象数组时,您不能使用foreach循环