Пример #1
0
 public function closeCartAction($cartId = 0)
 {
     $cart = Ecommerce\Cart::get((int) $cartId);
     $result = new Server\Result();
     if ($cart && $cart->cart_status_id != 5) {
         $cart->cart_status_id = 5;
         $cart->save();
         $result->successMsg = 'Заказ был завершен';
         $result->send();
     }
     $result->success = false;
     $result->content = 'Такая корзина не найдена';
     $result->send();
 }
Пример #2
0
<?php

$cart = !empty($_SESSION['cart']['cart_id']) ? Ecommerce\Cart::get((int) $_SESSION['cart']['cart_id']) : false;
$count = $cart ? count($cart->cartItems) : 0;
$sum = $cart ? $cart->sum : 0;
?>
<a href ='/ecommerce/cart'> 
    В корзине <?php 
echo $count;
?>
 <?php 
echo Tools::getNumEnding($count, ['товар', 'товара', 'товаров']);
?>
  (<?php 
echo $sum;
?>
р.)
</a>
Пример #3
0
 public function getCurCart($create = true)
 {
     $cart = false;
     if (!empty($_SESSION['cart']['cart_id'])) {
         $cart = Ecommerce\Cart::get((int) $_SESSION['cart']['cart_id']);
     }
     if (!$cart && $create) {
         $cart = new Ecommerce\Cart();
         $cart->cart_status_id = 1;
         $cart->user_id = Users\User::$cur->id;
         $userCard = \Ecommerce\Card\Item::get(\Users\User::$cur->id, 'user_id');
         if ($userCard) {
             $cart->card_item_id = $userCard->id;
         }
         $cart->save();
         $_SESSION['cart']['cart_id'] = $cart->id;
     }
     return $cart;
 }
Пример #4
0
 public function orderDetailAction($id = 0)
 {
     $cart = Ecommerce\Cart::get((int) $id);
     if ($cart->user_id != Users\User::$cur->id) {
         $this->url->redirect('/', 'Это не ваша корзина');
     }
     $bread[] = ['text' => 'Каталог', 'href' => '/ecommerce'];
     $bread[] = ['text' => 'Корзина', 'href' => '/ecommerce/cart'];
     $bread[] = ['text' => 'Заказ: №' . $cart->id, 'href' => '/ecommerce/cart/orderDetail/' . $cart->id];
     $this->view->setTitle('Заказ №' . $cart->id);
     $this->view->page(['data' => compact('cart', 'bread')]);
 }