Add hook to update cache on db write.
authorMaxime Bourget <bmx007@gmail.com>
Tue, 4 Jun 2013 21:06:52 +0000 (22:06 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Tue, 4 Jun 2013 21:06:52 +0000 (22:06 +0100)
hooks.php
item_schedule.php

index 019b6affb13cdeefce212cc0373f2968d6bf59c2..0bf5ad166e40b1e7181685d197d7fba70171e090 100644 (file)
--- a/hooks.php
+++ b/hooks.php
@@ -80,5 +80,17 @@ class hooks_order_line_extra extends hooks {
 
                        return max($qoh - $quantity_before, 0);
                }
+
+               function db_postwrite($cart, $trans_type) {
+                       if(!is_a($cart, "Cart") ) return;
+
+                       // It's a cart. Find all the stock_id and update the cache table 
+                       foreach($cart->line_items as $line_no => $item) {
+                               $stock_id = $item->stock_id;
+                               update_queue_quantity_for_item($stock_id);
+                               update_qoh_for_item($stock_id);
+                       }
+       
+               }
 }
 ?>
index 5e47ec5d8106348c33b5fae7975ddb973488a3ea..accb8da14034b75e4b37561ccb3dd7a7ad2f82b2 100644 (file)
@@ -51,7 +51,7 @@ else {
 }
 
 if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule') ;
-else update_queue_quantities() && update_qoh_for_item();
+//else update_queue_quantities() && update_qoh_for_item();
 
 
 //if (!@$_GET['popup'])