Index: uc_stock.module =================================================================== --- uc_stock.module (revision 10) +++ uc_stock.module (working copy) @@ -241,8 +241,8 @@ * @return * The result of drupal_mail(). */ -function _uc_stock_send_mail($order, $stock) { - $token_filters = array('global' => NULL, 'order' => $order, 'stock' => $stock); +function _uc_stock_send_mail($order, $product, $stock) { + $token_filters = array('global' => NULL, 'order' => $order, 'node' => $product, 'stock' => $stock); $account = user_load(array('uid' => $order)); $to = variable_get('uc_stock_threshold_notification_recipients', variable_get('uc_store_email', ini_get('sendmail_from'))); @@ -294,9 +294,16 @@ // Load the new stock record $stock = db_fetch_object(db_query("SELECT * FROM {uc_product_stock} WHERE sku = '%s'", $product->model)); + // Load node with all product token values. + $node = node_load($product->nid); + + // Let other modules hook into to change model name, i.e. if two different models share same stock + // or if you want another labeling at the threshold mail and the order comment. + module_invoke_all('uc_stock_decremented', $node, $product); + // Should we notify? if (variable_get('uc_stock_threshold_notification', FALSE) && $stock->stock <= $stock->threshold) { - _uc_stock_send_mail($order, $stock); + _uc_stock_send_mail($order, $node, $stock); } // Save a comment about the stock level.