diff --git a/uc_stock/uc_stock.admin.inc b/uc_stock/uc_stock.admin.inc index 2e75212..b8fcfe0 100644 --- a/uc_stock/uc_stock.admin.inc +++ b/uc_stock/uc_stock.admin.inc @@ -34,7 +34,7 @@ function uc_stock_settings_form() { '#type' => 'textarea', '#title' => t('Message text'), '#default_value' => variable_get('uc_stock_threshold_notification_message', uc_get_message('uc_stock_threshold_notification_message')), - '#description' => t('The message the user receives when the stock level reaches its threshold value (uses global, order, and stock tokens).', array('!token-help-page' => url('admin/store/help/tokens'))), + '#description' => t('The message the user receives when the stock level reaches its threshold value (uses global, order, product and stock tokens).', array('!token-help-page' => url('admin/store/help/tokens'))), '#rows' => 10, ); $form['uc_stock_threshold_notification_format'] = filter_form(variable_get('uc_stock_threshold_notification_format', FILTER_FORMAT_DEFAULT), NULL, array('uc_stock_threshold_notification_format')); diff --git a/uc_stock/uc_stock.module b/uc_stock/uc_stock.module index f4d12be..d7ef70b 100644 --- a/uc_stock/uc_stock.module +++ b/uc_stock/uc_stock.module @@ -241,17 +241,17 @@ function uc_stock_is_active($sku) { * * @param $order * The order object that tripped the threshold limit. - * @param $product - * The product object that is associated with the SKU. + * @param $node + * The node object that is associated with the SKU/model. * @param $stock * The stock level object that contains the stock level and SKU. * * @return * The result of drupal_mail(). */ -function _uc_stock_send_mail($order, $stock) { +function _uc_stock_send_mail($order, $node, $stock) { $account = uc_order_user_load($order); - $token_filters = array('global' => NULL, 'order' => $order, 'user' => $account, 'stock' => $stock); + $token_filters = array('global' => NULL, 'order' => $order, 'user' => $account, 'stock' => $stock, 'node' => $node); $to = variable_get('uc_stock_threshold_notification_recipients', uc_store_email()); $to = explode(',', $to); @@ -330,7 +330,10 @@ function uc_stock_adjust_product_stock($product, $key, $order) { // Should we notify? if (variable_get('uc_stock_threshold_notification', FALSE) && $stock->stock <= $stock->threshold) { - _uc_stock_send_mail($order, $stock); + // Load node object to enable all product token values + $node = node_load($product->nid); + // Notify + _uc_stock_send_mail($order, $node, $stock); } // Save a comment about the stock level.