function commerce_invoice_receipt_mail in Commerce Invoice Receipt 7
Same name and namespace in other branches
- 7.2 commerce_invoice_receipt.module \commerce_invoice_receipt_mail()
Implements hook_mail().
File
- ./
commerce_invoice_receipt.module, line 240 - Provides a printable invoice receipt along with HTML mailing rules.
Code
function commerce_invoice_receipt_mail($key, &$message, $params) {
$langcode = isset($message['language']) ? $message['language']->language : NULL;
$options = array(
'langcode' => $langcode,
'context' => '',
);
switch ($key) {
// Setup an e-mailed invoice.
case 'invoice':
$styles[] = array(
'type' => 'file',
'media' => 'all',
'data' => commerce_invoice_receipt_css_path(),
'group' => CSS_DEFAULT,
'every_page' => FALSE,
'weight' => 0,
'preprocess' => FALSE,
'browsers' => array(),
);
$html = drupal_get_css($styles);
if (module_exists('views_ui')) {
views_ui_contextual_links_suppress(TRUE);
}
$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);
if (isset($params['headers'])) {
$message['headers'] = $params['headers'];
}
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed;';
$message['subject'] = isset($params['subject']) ? $params['subject'] : t('Your Order Invoice', array(), $options);
$html .= theme('commerce_order_invoice_view', array(
'info' => $invoice_info,
'order' => $params['order'],
));
$message['body'][] = _emogrifier_process($html, NULL, NULL, NULL, NULL, NULL);
break;
}
}