Exemple #1
0
        <div class="row">
            <?php 
echo $this->render('/menu/_sidebar', ['modelGoodsCategories' => $modelGoodsCategories, 'modelBrends' => $modelBrends, 'modelBanner' => $modelBanner, 'PRICE_1' => $PRICE_1, 'PRICE_2' => $PRICE_2]);
?>

            <div class="col-sm-9 padding-right target-goods">
                <div class="features_items" id="start_animation"><!--features_items-->
                    <h2 class="title text-center">Товары</h2>
                    <?php 
if ($modelNewGoods) {
    ?>
                    <?php 
    foreach ($modelNewGoods as $good) {
        ?>
                        <?php 
        $inCart = Cart::_isItemAlreadyInCart($good->id);
        ?>

                        <div class="col-sm-4">
                            <div class="product-image-wrapper">
                                <div class="single-products img-<?php 
        echo $good->id;
        ?>
">
                                    <div class="productinfo text-center">
                                        <a href="/shop/detail?item=<?php 
        echo $good->id;
        ?>
"><img
                                                src="<?php 
        echo $Module::getGoodImage($good->image);
 public function actionAddToManyCart()
 {
     $arrResult = [];
     $iP = Yii::$app->session->id;
     $good_id = Yii::$app->request->post('good_id');
     $total = Yii::$app->request->post('total');
     // если есть этот товар в корзине то просто увеличить его количество на 1
     $isItemInCart = Cart::_isItemAlreadyInCart($good_id);
     if ($isItemInCart) {
         Cart::updateItemQuantityUpMany($good_id, $total);
     } else {
         $model = new Cart();
         $model->ip = Yii::$app->session->id;
         $model->goods_id = $good_id;
         $model->quantity = $total;
         $model->price = Goods::getPriceById($good_id);
         $model->category_id = Goods::getCategoryById($good_id);
         $model->brend_id = Goods::getBrendById($good_id);
         //$model->validate();
         //vd($model->getErrors());
         $model->save();
     }
     $quantityInCart = Cart::getQountAllByIp($iP);
     $arrResult['quantity'] = $quantityInCart;
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return $arrResult;
 }