1

I need to use the greeting as "Hello customer_firstname" in Invoice emails.

In the Invoice email template file invoice_new.html file, the following line is written, however it is showing the full name of the customer.

Hello, {{htmlescape var=$order.getCustomerFirstname()}
Daan
  • 2,680
  • 20
  • 39
user3401141
  • 135
  • 4
  • 14

3 Answers3

3

Try

{{var order.getCustomerFirstname()}}

<h4>Ficou com d&uacute;vidas? {{var order.getCustomerFirstname()}}</h4>
0

I found a solution where I modified the class Mage_Sales_Model_Order a little and added a new Method called "getCustomerOnlyFirstName" as shown below ::

The class "Mage_Sales_Model_Order" can be found in app\code\core\Mage\Sales\Model\Order.php path..

public function getCustomerOnlyFirstName()
{
  $name = trim($this->getCustomerName());
  $pos = strpos($name," ");

  if($pos !== false) /// FirstName can be extracted
  {
     $name = trim(substr( $name, 0, $pos ));
  }

  return $name; 
}

And in Email templates ( invoice_new.html and invoice_new_guest.html ), I had to write the following lines to get the things done ...

Hello, {{htmlescape var=$order.getCustomerOnlyFirstName()}}

It worked perfectly.

user3401141
  • 135
  • 4
  • 14
0

Try

<p class="greeting">{{trans "%name," name=$order.getBillingAddress().getFirstname()}}</p>
Liam Mitchell
  • 1,001
  • 13
  • 23