function commerce_invoice_receipt_mail in Commerce Invoice Receipt 7.2
Same name and namespace in other branches
- 7 commerce_invoice_receipt.module \commerce_invoice_receipt_mail()
Implements hook_mail().
File
- ./
commerce_invoice_receipt.module, line 176 - Provides a printable invoice receipt along with HTML mailing rules.
Code
function commerce_invoice_receipt_mail($key, &$message, $params) {
// Set the default language.
$langcode = isset($message['language']) ? $message['language']->language : NULL;
$options = array(
'langcode' => $langcode,
'context' => '',
);
switch ($key) {
// Setup an e-mailed invoice.
case 'invoice':
$build = entity_view('commerce_order', array(
$params['order']->order_id => $params['order'],
), 'invoice', NULL, TRUE);
$invoice_info = _commerce_invoice_receipt_get_invoice_info($params['order'], $build);
// Prepare the message headers.
if (isset($params['headers'])) {
$message['headers'] = $params['headers'];
}
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed;';
if (isset($params['cc'])) {
$message['headers']['Cc'] = $params['cc'];
}
if (isset($params['bcc'])) {
$message['headers']['Bcc'] = $params['bcc'];
}
// Get the email subject.
$message['subject'] = $params['subject'];
// Theme order invoice.
$html = theme('commerce_invoice_receipt', array(
'info' => $invoice_info,
'order' => $params['order'],
));
// Get formatted output.
$message['body'][] = _commerce_invoice_receipt_prepare_output($html);
break;
}
}