コード例 #1
0
 /**
  * AJAX
  * Добавление товара в корзину
  * REQUEST
  * - id - int - идентификатор товара gs_unions_shop_product.id
  *
  * @return string
  */
 public function actionBasket_add()
 {
     $id = self::getParam('id');
     $product = Product::find($id);
     if (is_null($product)) {
         return self::jsonErrorId(101, 'Не найден товар');
     }
     $count = Basket::add($product);
     return self::jsonSuccess($count);
 }
コード例 #2
0
ファイル: basket.php プロジェクト: Makeyko/galaxysss
?>
</h1>
        </div>



        <?php 
$ids = [];
foreach (\app\modules\Shop\services\Basket::get() as $item) {
    $ids[] = $item['id'];
}
$unionRows = \app\models\Shop\Product::query(['in', 'gs_unions_shop_product.id', $ids])->innerJoin('gs_unions', 'gs_unions.id = gs_unions_shop_product.union_id')->select(['gs_unions.*'])->groupBy(['gs_unions_shop_product.union_id'])->all();
for ($i = 0; $i < count($unionRows); $i++) {
    $unionRows[$i]['productList'] = \app\models\Shop\Product::query(['union_id' => $unionRows[$i]['id']])->andWhere(['in', 'gs_unions_shop_product.id', $ids])->all();
    for ($j = 0; $j < count($unionRows[$i]['productList']); $j++) {
        foreach (\app\modules\Shop\services\Basket::get() as $d) {
            if ($unionRows[$i]['productList'][$j]['id'] == $d['id']) {
                $unionRows[$i]['productList'][$j]['count'] = $d['count'];
                continue;
            }
        }
    }
}
?>

        <table class="table table-striped table-hover">
            <tr>
                <th>
                    #
                </th>
                <th>
コード例 #3
0
ファイル: menu.php プロジェクト: Makeyko/galaxysss
                                <li><a href="<?php 
    echo Url::to(['auth/password_recover']);
    ?>
">Напомнить пароль</a></li>
                                <li><a href="<?php 
    echo Url::to(['auth/registration']);
    ?>
">Регистрация</a></li>
                            </ul>
                        </div>
                    </li>
                <?php 
} else {
    ?>
                    <?php 
    $count = Basket::getCount();
    $this->registerJs('$("#basketCount").tooltip({placement:"left"})');
    ?>
                    <?php 
    if ($count > 0) {
        ?>
                        <li>
                            <a style="
                                padding-right: 0px;
                                padding-bottom: 0px;
                            " href="<?php 
        echo Url::to(['cabinet_shop/basket']);
        ?>
">
                                <span id="basketCount" class="label label-success" title="Корзина">
                                    <?php