コード例 #1
0
ファイル: smalcart.php プロジェクト: SergM2014/shopmvc5
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: updateCart.php プロジェクト: SergM2014/shopmvc5
 function index()
 {
     if (isset($_POST['to_up'])) {
         $arr = explode('&', $_POST['to_up']);
         foreach ($arr as $one) {
             $one = explode('=', $one);
             $arr1[$one[0]] = $one[1];
         }
     }
     if (!$arr1) {
         header('Location:' . URL . 'busket');
     }
     foreach ($_SESSION['cart'] as $id => $qty) {
         if ($_POST[$id] == '0' || $arr1[$id] == '') {
             unset($_SESSION['cart'][$id]);
         } else {
             $_SESSION['cart'][$id] = $arr1[$id];
         }
     }
     $controller = new Application_Controllers_Cart();
     $controller->totalItems($_SESSION['cart']);
     $controller->totalPrice($_SESSION['cart']);
     Lib_SmalCart::getInstance()->setCartData();
     header('Location:' . URL . 'busket');
 }
コード例 #3
0
ファイル: order.php プロジェクト: TestForVodka/ishop
 function index()
 {
     $this->dislpay_form = true;
     // показывать форму ввода данных
     if (isset($_REQUEST["to_order"])) {
         // если пришли данные с формы
         $model = new Application_Models_Order();
         //создаем модель заказа
         $error = $model->isValidData($_REQUEST);
         //проверяем на корректность вода
         if ($error) {
             $this->error = $error;
         } else {
             //если ошибок нет, то добавляем заказ в БД
             $order_id = $model->addOrder();
             Lib_SmalCart::getInstance()->setCartData();
             // пересчитываем маленькую корзину
             header('Location: /order?thanks=' . $order_id);
             exit;
         }
     }
     if (isset($_REQUEST["thanks"])) {
         //формируем сообщение
         $this->message = "Ваша заявка <strong>№ " . $_REQUEST["thanks"] . "</strong> принята";
         $this->dislpay_form = false;
         //  форму ввода данных больше не покзываем
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: SergM2014/shopmvc5
 function index()
 {
     $model = new Application_Models_Index();
     $mod1 = $model->getSlider();
     $mod2 = $model->getCarousel();
     $mod3 = $model->isCarousel();
     $this->mod1 = $mod1;
     $this->mod2 = $mod2;
     $this->mod3 = $mod3;
     Lib_SmalCart::getInstance()->getCokieCart();
 }
コード例 #5
0
ファイル: catalog.php プロジェクト: TestForVodka/ishop
 function index()
 {
     if ($_REQUEST['in-cart-product-id']) {
         $cart = new Application_Models_Cart();
         $cart->addToCart($_REQUEST['in-cart-product-id']);
         Lib_SmalCart::getInstance()->setCartData();
         header('Location: /catalog');
         exit;
     }
     $model = new Application_Models_Catalog();
     $Items = $model->getList();
     $this->Items = $Items;
 }
コード例 #6
0
ファイル: cart.php プロジェクト: SergM2014/shopmvc5
 function totalPrice($cart)
 {
     $mod = new Application_Models_Cart();
     $price = 0.0;
     if (is_array($cart)) {
         foreach ($cart as $id => $qty) {
             $item_price = $mod->getPrice($id);
             $price += $item_price * $qty;
         }
     }
     $_SESSION['total_price'] = $price;
     Lib_SmalCart::getInstance()->setTotalPrice();
     return false;
 }
コード例 #7
0
ファイル: busket.php プロジェクト: SergM2014/shopmvc5
 function index()
 {
     if (isset($_POST['order'])) {
         $order = AppUser::cleanInput($_POST);
         $this->order = $order;
         $model = new Application_Models_Order();
         $error = $model->insertBusket($order);
         if (!empty($error)) {
             $this->error = $error;
         } else {
             Lib_SmalCart::getInstance()->deleteCookies();
         }
         if (empty($error)) {
             $this->success = 1;
         }
     }
 }
コード例 #8
0
ファイル: cart.php プロジェクト: TestForVodka/ishop
 function index()
 {
     $model = new Application_Models_Cart();
     if ($_REQUEST['refresh']) {
         // если пользователь изменил данные в корзине
         $list_Item_Id = $_REQUEST;
         foreach ($list_Item_Id as $Item_Id => $new_count) {
             //пробегаем по массиву , находим пометки на удаление и на изменение количества
             $id = "";
             if (substr($Item_Id, 0, 5) == "item_") {
                 $id = substr($Item_Id, 5);
                 $count = $new_count;
             } elseif (substr($Item_Id, 0, 4) == "del_") {
                 $id = substr($Item_Id, 4);
                 $count = 0;
             }
             if ($id) {
                 $array_product_id[$id] = (int) $count;
             }
         }
         $model->refreshCart($array_product_id);
         // передаем в модель данные для обновления корзины
         Lib_SmalCart::getInstance()->setCartData();
         // пересчитываем маленькую корзину
         header('Location: /cart');
         exit;
     }
     if ($_REQUEST['clear']) {
         // если пользователь изменил данные в корзине
         $model->clearCart();
         // передаем в модель данные для обновления корзины
         Lib_SmalCart::getInstance()->setCartData();
         // пересчитываем маленькую корзину
         header('Location: /cart');
         exit;
     }
     $big_cart = $model->printCart();
     //выводим список позиций к заказу()
     $this->big_cart = $big_cart;
     //в представлении он будет доступен через переменную $big_cart
     $this->empty_cart = $model->isEmptyCart();
 }
コード例 #9
0
ファイル: function.php プロジェクト: TestForVodka/ishop
function getSmalCart()
{
    return Lib_SmalCart::getInstance()->getCartData();
}