Call hooks on split.
authorMaxime Bourget <bmx007@gmail.com>
Sat, 8 Jun 2013 15:25:41 +0000 (16:25 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sat, 8 Jun 2013 15:25:41 +0000 (16:25 +0100)
hooks.php
includes/order_lines.inc

index 818fe7a3fc2ac3219151eb0efba5f05e8012fbfa..1df1ef5cc4387d555dc9908bdd4f0ec53794a7b9 100644 (file)
--- a/hooks.php
+++ b/hooks.php
@@ -83,7 +83,7 @@ class hooks_order_line_extra extends hooks {
                }
 
                function db_postwrite($cart, $trans_type) {
-                       if(!is_a($cart, "Cart") ) return;
+                       if(is_a($cart, "Cart")) {
 
                        // It's a cart. Find all the stock_id and update the cache table 
                        foreach($cart->line_items as $line_no => $item) {
@@ -91,10 +91,11 @@ class hooks_order_line_extra extends hooks {
                                update_queue_quantity_for_item($stock_id);
                                update_qoh_for_item($stock_id);
                        }
+                       }
 
                        // update null fields of new entered orders.
                        //
-               $types = array(ST_SALESORDER);
+               $types = array(ST_SALESORDER, 'order_xtra');
                if(in_array($trans_type, $types)) update_order_detail_defaults();
        
                }
index 9366ecb97779182e80973b2bc9c7413cbfed6d90..cbaedc1d00a28011df1636ef5f5f4afadd0c6674 100644 (file)
@@ -71,7 +71,10 @@ function split_order_details() {
        if(!isset($_POST['Split']) || $_POST['Split'] != 'Split')  return;
        $splitter = new Splitter($_POST);
        begin_transaction();
+       $cart  = null;
+       hook_db_prewrite($cart, 'order_xtra');
                if($splitter->splitAll()) display_warning("Items have been split.");
+       hook_db_postwrite($cart, 'order_xtra');
        commit_transaction();
 }