Commit 8fa44a600a09f25fae5c5544e4a9bad42a280816

Authored by Anastasia
1 parent a5647273

bug fix artbox-order

controllers/OrderController.php
@@ -213,6 +213,7 @@ @@ -213,6 +213,7 @@
213 $model = $this->findModel($id); 213 $model = $this->findModel($id);
214 214
215 if ($model->load(Yii::$app->request->post()) && $model->save() && !empty(\Yii::$app->request->post('OrderProduct'))) { 215 if ($model->load(Yii::$app->request->post()) && $model->save() && !empty(\Yii::$app->request->post('OrderProduct'))) {
  216 + //print_r(\Yii::$app->request->post('OrderProduct')); die();
216 OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id); 217 OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id);
217 return $this->redirect( 218 return $this->redirect(
218 [ 219 [
models/OrderProduct.php
@@ -143,6 +143,7 @@ @@ -143,6 +143,7 @@
143 ] 143 ]
144 ) 144 )
145 ->all(); 145 ->all();
  146 + // print_r($orderProducts); die();
146 $newItems = []; 147 $newItems = [];
147 foreach ($items as $item) { 148 foreach ($items as $item) {
148 $id = $item[ 'variant_id' ]; 149 $id = $item[ 'variant_id' ];
@@ -150,7 +151,7 @@ @@ -150,7 +151,7 @@
150 foreach ($orderProducts as $orderProduct) { 151 foreach ($orderProducts as $orderProduct) {
151 if ($orderProduct->variant_id == $id) { 152 if ($orderProduct->variant_id == $id) {
152 $orderProduct->count = $count; 153 $orderProduct->count = $count;
153 - break 2; 154 + continue 2;
154 } 155 }
155 } 156 }
156 /** 157 /**
@@ -172,9 +173,11 @@ @@ -172,9 +173,11 @@
172 } 173 }
173 } 174 }
174 $orderProducts = array_merge($orderProducts, $newItems); 175 $orderProducts = array_merge($orderProducts, $newItems);
  176 + // print_r($orderProducts); die();
175 foreach ($orderProducts as $orderProduct) { 177 foreach ($orderProducts as $orderProduct) {
176 - $orderProduct->save(); 178 + var_dump( $orderProduct->save());
177 } 179 }
  180 + // die();
178 return $orderProducts; 181 return $orderProducts;
179 } 182 }
180 } 183 }