Ejemplo n.º 1
0
 public function actionRemoveMoreQuantity()
 {
     $arrResult = [];
     $iP = Yii::$app->session->id;
     $good_id = Yii::$app->request->post('good_id');
     $goodPrice = Goods::getPriceById($good_id);
     // vd($good_id);
     $model = Cart::getItemById($good_id);
     $model->quantity = $model->quantity - 1;
     $model->price = $model->price - $goodPrice;
     $model->updateAttributes(['quantity', 'price']);
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $quantityInCart = Cart::getQountAllByIp($iP);
     $arrResult['new_quantity'] = $model->quantity;
     $arrResult['new_price'] = $model->price;
     $arrResult['total'] = $quantityInCart;
     return $arrResult;
 }