--- up_multi.module (revision 1380)
+++ up_multi.module (working copy)
@@ -246,10 +246,34 @@
 }
 
 function up_multi_stock_adjust($sku, $qty, $location) {
-    db_query("UPDATE {up_store_stock} SET stock_level = stock_level + %d WHERE model = '%s' AND store_id = '%d'", $qty, $sku, $location);
-    return db_result(db_query("SELECT stock_level FROM up_store_stock WHERE model = '%s' AND store_id = %d", $sku, $location));
-}
 
+  /**
+   * Allow other modules to adjust sku, the qty and location
+   * (or perform some other type of processing).
+   *
+   * Implementations of hook_up_multi_stock_adjust receive $sku, $qty and 
+   * $location as parameters and should return an array with keys sku, qty and 
+   * location
+   */
+  foreach (module_implements('up_multi_stock_adjust') as $module) {
+    $hook_result = module_invoke($module, 'up_multi_stock_adjust', $sku, $qty, $location);
+    if (! is_array($hook_result)) {
+      throw new Exception(t('Invalid return value for implementation of hook up_multi_stock_adjust in module') . ' ' . $module);
+    };
+    if ( (! isset($hook_result['sku']))
+         || (! isset($hook_result['qty']))
+         || (! isset($hook_result['location']))) {
+      throw new Exception(t('Implementation of hook up_multi_stock_adjust does not return all required keys in module') . ' ' . $module);
+    };
+    $sku      = $hook_result['sku'];
+    $qty      = $hook_result['qty'];
+    $location = $hook_result['location'];
+  };
+
+  db_query("UPDATE {up_store_stock} SET stock_level = stock_level + %d WHERE model = '%s' AND store_id = '%d'", $qty, $sku, $location);
+  return db_result(db_query("SELECT stock_level FROM {up_store_stock} WHERE model = '%s' AND store_id = %d", $sku, $location));
+};
+

