Exemplo n.º 1
0
 private function deleteOrderlitemsByOrder($orderid, $ordertype){
     $conditions = array('order_id=? AND order_type=?', $orderid, $ordertype);
     $result = \Orderproduct::find('all', array('conditions' => $conditions));
     foreach($result as $data){
         $stck = $data->quantity;
         $prdid = $data->product_id;
         $data->delete();
         if($this->enablestock && !$this->enableordrdn){
             $prd = \Product::find($prdid);
             if($prd){
                 $newstock= $prd->stock + $stck;
                 $attributes = array(
                     "stock" => $newstock,
                     "stockvalue" => $newstock * $prd->unit_cp);
                 $prd->update_attributes($attributes);
             }
         }
     }
 }