}
            }
        }
        */
 }
 //FLAG ORDER MODE
 if (count($items_mto) > 0 || count($items_mmo) > 0) {
     //If there is at least 1 MTO or MMO, the DSO items will be saved as WMO
     if ($order_type == 'SP') {
         if (count($items_dso) > 0) {
             $class_jo->updateOrderItemMode($items_dso, 'WMO');
         }
         $class_jo->updateOrderItemMode($items_mmo, 'MMO');
     } else {
         if (count($items_dso) > 0) {
             $class_o->updateOrderItemMode($items_dso, 'WMO');
         }
         $class_o->updateOrderItemMode($items_mmo, 'MMO');
     }
 } else {
     //If there is no MMO and MTO then all items should be flagged as DSO (Full DSO)
     if ($orders_total[$order_key] == count($items_dso)) {
         //IF ALL ITEMS IS ALREADY INCLUDED
         if ($order_type == 'SP') {
             $class_jo->updateOrderItemMode($items_dso, 'DSO');
         } else {
             $class_o->updateOrderItemMode($items_dso, 'DSO');
         }
     } else {
         //IF NOT ALL ITEMS IS ALREADY INCLUDED, REQUERY ALL ITEMS
         if ($order_type == 'SP') {