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

时间:2012-10-26 01:05:48

标签: magento magento-1.7

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

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

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

我能够显示订单ID:

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

如果您有任何建议,请尽可能具体,因为我绝对是新手。

2 个答案:

答案 0 :(得分:7)

尝试将此添加到Success.phtml

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

了解详情:Get Order Increment ID in Magento

答案 1 :(得分:0)

尝试使用此代码

$_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();
}

希望这有帮助