function _uc_stock_send_mail in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_stock/uc_stock.module \_uc_stock_send_mail()
- 5 uc_stock/uc_stock.module \_uc_stock_send_mail()
- 6.2 uc_stock/uc_stock.module \_uc_stock_send_mail()
Emails administrator regarding any stock level thresholds hit.
Parameters
$order: The order object that tripped the threshold limit.
$node: The node object that is associated with the SKU/model.
$stock: The stock level object that contains the stock level and SKU.
Return value
The result of drupal_mail().
1 call to _uc_stock_send_mail()
- uc_stock_adjust_product_stock in uc_stock/
uc_stock.module - Decrement a product's stock.
File
- uc_stock/
uc_stock.module, line 217 - Allow ubercart products to have stock levels associated with their SKU
Code
function _uc_stock_send_mail($order, $node, $stock) {
$account = user_load($order->uid);
$token_filters = array(
'uc_order' => $order,
'user' => $account,
'uc_stock' => $stock,
'node' => $node,
);
$to = variable_get('uc_stock_threshold_notification_recipients', uc_store_email());
$to = explode(',', $to);
$from = uc_store_email_from();
$subject = variable_get('uc_stock_threshold_notification_subject', uc_get_message('uc_stock_threshold_notification_subject'));
$subject = token_replace($subject, $token_filters);
$body = variable_get('uc_stock_threshold_notification_message', uc_get_message('uc_stock_threshold_notification_message'));
$body = token_replace($body, $token_filters);
// Send to each recipient.
foreach ($to as $email) {
$sent = drupal_mail('uc_stock', 'threshold', $email, uc_store_mail_recipient_language($email), array(
'body' => $body,
'subject' => $subject,
'order' => $order,
'stock' => $stock,
), $from);
if (!$sent['result']) {
watchdog('uc_stock', 'Attempt to e-mail @email concerning stock level on sku @sku failed.', array(
'@email' => $email,
'@sku' => $stock->sku,
), WATCHDOG_ERROR);
}
}
}