开发者

Magento 1.5.1 - How can I add the customer's billing email address to success.phtml

开发者 https://www.devze.com 2023-04-12 07:37 出处:网络
I\'ve added the following code to the Magento 1.5.1 order confirmation page (success.pht开发者_StackOverflowml):

I've added the following code to the Magento 1.5.1 order confirmation page (success.pht开发者_StackOverflowml):

<?php
    $_order_id = Mage::getSingleton('checkout/session')->getLastOrderId(); // here I get the Oreder ID
    $_order->load($_order_id);
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $email = $customer->getEmail();  // To get Email Address of a customer.
?>

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

Unfortunately the email variable is empty/null.

Does anyone know how to efficiently get this data? Obtaining First and Last name would be a bonus.

Keep in mind that guest checkout is allowed, so we may not have a customer record in all cases. In any case, I need the billing email address assosicated with the order (guest checkout or not.)

Thanks!


If you got the Order object maybe you can use:

$order->getBillingAddress()->getEmail();

I think that this method it better because you can use it for Guest Customers too.


You have the order increment number ther so load the order and get the variable from order object

0

精彩评论

暂无评论...
验证码 换一张
取 消