Palanikumar
Palanikumar

Reputation: 1746

Customer name in newsletter subscription success email template

Im trying to include customer name in newsletter subscription success page. But I couldnt include customer name.

I have tried following variables in email template without successful. Im using magento 1.7.0.2

{{var customer.name}}
{{htmlescape var=$customer.name}}
{{var subscriber.name}}
{{htmlescape var=$customer.firstname}}
{{var subscriber.CustomerFirstname}}
{{var subscriber.getCustomerFirstname()}}
{{var subscriber.getSubscriberFullName()}} 

Upvotes: 0

Views: 5641

Answers (1)

Đorđe
Đorđe

Reputation: 33

You can get customer name by:

Rewriting a class Mage_Newsletter_Model_Subscriber with your class.

Rewriting a function sendConfirmationSuccessEmail() in which you can get customer by:

    $customer = Mage::getModel('customer/customer');
    $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
    $customer->loadByEmail($this->getEmail());

and then assign variable 'customer' to email template

    $email->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
        Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
        $this->getEmail(),
        $this->getName(),
        array('subscriber'=>$this, 'customer'=>$customer)
    );

- In newsletter_subscr_success.html you will have

   {{var customer.firstname}} {{var customer.lastname}}

or whatever you need from customer.

Upvotes: 2

Related Questions