コード例 #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
ファイル: buy.php プロジェクト: dram1008/bogdan
<?php

/* @var $this yii\web\View */
/* @var $model \cs\base\BaseForm */
/* @var $id int product_id bog_shop_product.id */
$this->title = 'Заказ';
$product = \app\models\Shop\Product::find($id);
$productPrice = $product->getField('price');
$this->registerJs(<<<JS
    \$('.field-request-address').hide();
    \$('input[name="Request[dostavka]"]').on('change', function() {
        var newPrice;
        if (\$(this).val() == 3 || \$(this).val() == 4) {
            \$('.field-request-address').show();
            newPrice = productPrice + 300;
        } else if (\$(this).val() == 5) {
            \$('.field-request-address').show();
            newPrice = productPrice + 1000;
        } else {
            \$('.field-request-address').hide();
            newPrice = productPrice;
        }
        \$('#productPriceForm').attr('value', newPrice);
        \$('#productPrice').html(newPrice);
    });
    \$('.paymentType').click(function () {
        \$('#paymentType').attr('value', \$(this).data('value'));
        if (!\$(this).hasClass('active')) {
            \$('.paymentType').removeClass('active');
            \$(this).addClass('active');
        }
コード例 #3
0
ファイル: Request.php プロジェクト: dram1008/bogdan
 /**
  * @return \app\models\Shop\Product
  */
 public function getProduct()
 {
     $product = Product::find($this->getField('product_id'));
     return $product;
 }
コード例 #4
0
 /**
  * Продукт
  *
  * @param $category string id_string
  * @param $union_id int идентификатор объединения
  * @param $id int идентификатор продукта gs_unions_shop_product.id
  *
  * @return string
  * @throws \cs\web\Exception
  */
 public function actionProduct($category, $union_id, $id)
 {
     $item = Union::find($union_id);
     if (is_null($item)) {
         throw new Exception('Нет такого объединения');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     if (is_null($categoryObject)) {
         throw new Exception('Не найдена категория');
     }
     $product = Product::find($id);
     if (is_null($product)) {
         throw new Exception('Не найден товар');
     }
     $treeNode = TreeNode::find($product->getField('tree_node_id'));
     $breadcrumbs = $categoryObject->getBreadCrumbs();
     $breadcrumbs = ArrayHelper::merge($breadcrumbs, [['url' => ['page/union_item', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => $item->getName()], ['url' => ['union_shop/index', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => 'Магазин'], ['url' => ['union_shop/category', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string'), 'shop_category' => $product->getField('tree_node_id')], 'label' => $treeNode->getField('name')], $product->getField('name')]);
     return $this->render(['union' => $item, 'shop' => $item->getShop(), 'breadcrumbs' => $breadcrumbs, 'category' => $categoryObject, 'treeNode' => $treeNode, 'product' => $product]);
 }