2

I've scanned many posts but cannot get to bottom of this one. I have created a custom Customer Information attribute and I need it to display on the New Order transactional email.

Any ideas? I have tried {{var customer.getAccountno()}} and a few others but it won't display.

My Code:

$installer = $this;
$installer->startSetup();


$installer->addAttribute("customer", "accountno",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Account Number",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => false,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "accountno");


$used_in_forms=array();

$used_in_forms[]="adminhtml_customer";
        $attribute->setData("used_in_forms", $used_in_forms)
        ->setData("is_used_for_customer_segment", true)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 1)
        ->setData("is_visible", 1)
        ->setData("sort_order", 100)
        ;
        $attribute->save();



$installer->endSetup();
0

to add the customer attribute in new order email, change the below file

Rewrite first sendNewOrderEmail() from app/code/core/Mage/Sales/Model/Order.php to your local codepool. Add $email in the template parameters.

$info = $this->getAccountno();
$mailer->setTemplateParams(array(
            'order'        => $this,
            'info'         => $info,
            'billing'      => $this->getBillingAddress(),
            'payment_html' => $paymentBlockHtml
        )
    );

Now you can access this variable like {{var info}} in the new sales order email template.

|improve this answer|||||
0

for transectional email, you need set value via controller or observer and than you use {{var customer.getAccountno()}} it will work.

|improve this answer|||||
0

Solution for Magento 1.9.x

{{var order.getCustomer().getData('your_customer_attribute_code')}}

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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