diff --git a/controllers/OrderController.php b/controllers/OrderController.php index df58b94..49904e7 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -213,6 +213,7 @@ $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save() && !empty(\Yii::$app->request->post('OrderProduct'))) { + //print_r(\Yii::$app->request->post('OrderProduct')); die(); OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id); return $this->redirect( [ diff --git a/models/OrderProduct.php b/models/OrderProduct.php index 6b902ef..febecef 100755 --- a/models/OrderProduct.php +++ b/models/OrderProduct.php @@ -143,6 +143,7 @@ ] ) ->all(); + // print_r($orderProducts); die(); $newItems = []; foreach ($items as $item) { $id = $item[ 'variant_id' ]; @@ -150,7 +151,7 @@ foreach ($orderProducts as $orderProduct) { if ($orderProduct->variant_id == $id) { $orderProduct->count = $count; - break 2; + continue 2; } } /** @@ -172,9 +173,11 @@ } } $orderProducts = array_merge($orderProducts, $newItems); + // print_r($orderProducts); die(); foreach ($orderProducts as $orderProduct) { - $orderProduct->save(); + var_dump( $orderProduct->save()); } + // die(); return $orderProducts; } } -- libgit2 0.21.4