Jump to content

Invoice number in mails


ivankaa

Recommended Posts

Hi everybody,

can someone help me how to get invoice number into mail, e.g. bankwire mail? I use invoice number as variable symbol in PDF invoice and I also want to send this variable symbol with other informations about bankwire payment. I tried some code modification but without success.

Thank for help.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

So here is the solution :)

 

1. file classes/OrderHistory.php

Get invoice number from database and send it to data array:

$result = Db::getInstance()->getRow('

 

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, o.`invoice_number`

FROM `'._DB_PREFIX_.'order_history` oh

LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`

LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`

LEFT JOIN `'._DB_PREFIX_.'order_state` os ON oh.`id_order_state` = os.`id_order_state`

LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)

WHERE oh.`id_order_history` = '.(int)($this->id).' AND os.`send_email` = 1');

 

if (isset($result['template']) AND Validate::isEmail($result['email']))

{

$topic = $result['osname'];

$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order);

if ($templateVars)

$data = array_merge($data, $templateVars);

$order = new Order((int)$this->id_order);

$data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);

$data['{order_name}'] = sprintf("#%06d", (int)$order->id);

$data['{invoice_number}'] = (int) $order->invoice_number;

 

2. file mails/en/bankwire.html

Show invoice number:

{invoice_number}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...