function uc_order_mail in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_order/uc_order.module \uc_order_mail()
- 6.2 uc_order/uc_order.module \uc_order_mail()
Implements hook_mail().
File
- uc_order/
uc_order.module, line 625
Code
function uc_order_mail($key, &$message, $params) {
$langcode = isset($message['language']) ? $message['language']->language : NULL;
// Build the appropriate message parameters based on the e-mail key.
switch ($key) {
// Setup an e-mailed invoice.
case 'invoice':
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = t('Your Order Invoice', array(), array(
'langcode' => $langcode,
));
$message['from'] = uc_store_email_from();
$message['body'][] = theme('uc_order', array(
'order' => $params['order'],
'op' => 'admin-mail',
'template' => variable_get('uc_cust_order_invoice_template', 'customer'),
));
break;
// Setup a custom e-mail defined by an action on a predicate.
case 'action-mail':
// Assemble an email message from the conditional actions settings.
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['from'] = $params['from'];
// Perform token replacement on the subject and body.
$subject = token_replace($params['subject'], $params['replacements'], $langcode ? array(
'language' => $message['language'],
) : array());
$body = token_replace($params['message'], $params['replacements'], $langcode ? array(
'language' => $message['language'],
) : array());
// Strip newline characters from e-mail subjects.
// @todo: Maybe drupal_mail_send() should do this?
$message['subject'] = str_replace(array(
"\r\n",
"\r",
"\n",
), ' ', $subject);
// Apply an input format to the message body if specified.
if (isset($params['format'])) {
$message['body'] = explode("\n", check_markup($body, $params['format'], $langcode));
}
else {
$message['body'] = explode("\n", $body);
}
break;
}
}