2

How can I insert the customer’s email into the email templates for both guest and registered customers?

I came across this answer but it seems a bit too old now as I am using Magento 1.8. The code looks different now.

The code from the answer for app/code/core/Mage/Sales/Model/Order.php,

foreach ($sendTo as $recipient) {
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId()))
->sendTransactional(
$template,
Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $this->getStoreId()),
$recipient['email'],
$recipient['name'],
array(
'order'         => $this,
'billing'       => $this->getBillingAddress(),
'payment_html'  => $paymentBlock->toHtml(),
'guestemailvalue' => $recipient['email']
)
);
}

the code from the 1.8 for app/code/core/Mage/Sales/Model/Order.php,

    // Set all required params and send emails
    $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
    $mailer->setStoreId($storeId);
    $mailer->setTemplateId($templateId);
    $mailer->setTemplateParams(array(
            'order'        => $this,
            'billing'      => $this->getBillingAddress(),
            'payment_html' => $paymentBlockHtml
        )
    );
    $mailer->send();

Any ideas?

1 Answer 1

1

tealau, for getting new order email goto

app/locale/yourlanguae/template/email/sales/

magento used different different email template for guest and register

find and here you find list order email and you can getusing

 {{htmlescape var=$order.getCustomerEmail()}} 
13
  • Thanks Amit. do I have to put that in the curly brackets like this {{var order.getBillingAddress().email()}}?
    – Run
    Aug 29, 2014 at 15:09
  • just tested it but no email printed in the email at all :(
    – Run
    Aug 29, 2014 at 15:14
  • can you tell me on which email template you have using
    – Amit Bera
    Aug 29, 2014 at 15:14
  • is neworder email ?
    – Amit Bera
    Aug 29, 2014 at 15:14
  • 1
    can you try this {{htmlescape myemail=$order.getCustomerEmail()}}
    – Amit Bera
    Aug 29, 2014 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.