Ejemplo n.º 1
0
 public function actionLogout()
 {
     // Удаляем информацию о пользователе из сессии
     unset($_SESSION['user']);
     Cart::clear();
     // Перенаправляем пользователя на главную страницу
     header('Location:/');
 }
Ejemplo n.º 2
0
 public function getDone(Request $request)
 {
     $id = $request->get('paymentId');
     $token = $request->get('token');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     \Cart::clear();
     return view('frontend.checkout.done')->with('categories', Category::all())->with('pay', $executePayment);
 }
Ejemplo n.º 3
0
 /**
  * Action для страницы "Оформление покупки"
  */
 public function actionCheckout()
 {
     // Получаем данные из корзины
     $productsInCart = Cart::getProductsInCart();
     // Если товаров нет, отправляем пользователи искать товары на главную
     if ($productsInCart == false) {
         header("Location: /");
     }
     // Список категорий для левого меню
     $categories = Category::getCategoriesList();
     // Находим общую стоимость
     $productsIds = array_keys($productsInCart);
     $products = Product::getProductsByIds($productsIds);
     $totalPrice = Cart::getTotalPrice($products);
     // Количество товаров
     $totalQuantity = Cart::cartItems();
     // Поля для формы
     $userName = false;
     $userPhone = false;
     $userComment = false;
     // Статус успешного оформления заказа
     $result = false;
     // Проверяем является ли пользователь гостем
     if (!User::isGuest()) {
         // Если пользователь не гость
         // Получаем информацию о пользователе из БД
         $userId = User::checkLogged();
         $user = User::getUserById($userId);
         $userName = $user['name'];
     } else {
         // Если гость, поля формы останутся пустыми
         $userId = false;
     }
     // Обработка формы
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $userName = $_POST['userName'];
         $userPhone = $_POST['userPhone'];
         $userComment = $_POST['userComment'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkName($userName)) {
             $errors[] = 'Неправильное имя';
         }
         if (!User::checkPhone($userPhone)) {
             $errors[] = 'Неправильный телефон';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Сохраняем заказ в базе данных
             $result = Order::save($userName, $userPhone, $userComment, $userId, $productsInCart);
             if ($result) {
                 // Если заказ успешно сохранен
                 // Оповещаем администратора о новом заказе по почте
                 $adminEmail = '*****@*****.**';
                 $message = 'Cписок заказов';
                 $subject = 'Новый заказ!';
                 mail($adminEmail, $subject, $message);
                 // Очищаем корзину
                 Cart::clear();
             }
         }
     }
     // Подключаем вид
     require_once ROOT . '/views/cart/checkout.php';
     return true;
 }
Ejemplo n.º 4
0
 public function actionSubmit()
 {
     if (isset($_POST)) {
         // Получаем данные из формы
         $name = $_POST['name'];
         $email = $_POST['email'];
         $phone = $_POST['phone'];
         // Валидация данных
         $message = Cart::validation($name, $phone);
         if ($message['name'] || $message['phone']) {
             require_once ROOT . '/views/cart/submit_err.php';
         } else {
             // Если ошибок нет, сохраняем данные о пользователе в базе данных
             $id = Cart::saveUser($name, $email, $phone);
             // Формируем описание заказа в виде строк
             $order = Cart::getServices();
             if ($order) {
                 $servicesIds = array_keys($order);
                 $services = Services::getServicesDetailed($servicesIds);
                 $totalSum = Cart::getTotalSum($services);
                 $orderDetails = 'Новый заказ ';
                 $orderDetails .= 'от пользователя: id=' . $id . ', имя: ' . $name . ', email: ' . $email . ', тел.: ' . $phone . '. ';
                 foreach ($services as $service) {
                     $orderDetails .= $service["name"] . ' (id = ' . $service["id"] . ') по цене ' . $service["price"] . ' грн. в количестве ' . $order[$service["id"]] . '. ';
                 }
                 $orderDetails .= 'На общую сумму ' . $totalSum . ' грн.';
                 // Сохраняем заказ в базе данных
                 $orderId = Cart::saveOrder($id, $orderDetails);
             }
             // Если заказ сохранен
             if ($orderId != 0) {
                 // Оповещаем администратора о новом заказе по почте
                 $adminEmail = '*****@*****.**';
                 $subject = 'Новый заказ! Номер ' . $orderId;
                 $message = 'От пользователя: id=' . $id . ', имя: ' . $name . ', email: ' . $email . ', тел.: ' . $phone . '.';
                 // Если письмо успешно отправлено
                 if (mail($adminEmail, $subject, $message)) {
                     // Очищаем корзину
                     Cart::clear();
                 }
             }
             require_once ROOT . '/views/cart/done.php';
         }
     } else {
         require_once ROOT . '/views/cart/submit.php';
     }
     return true;
 }
Ejemplo n.º 5
0
 public function pay()
 {
     $this->is_login();
     $userinfo = session('P');
     $wxpay_config = $this->ag_hongbao_config();
     if (empty($wxpay_config['Allow_type'])) {
         $this->error('暂不支持任何形式付款');
     }
     if (IS_POST && count($_SESSION['cart']) > 0) {
         import('@.ORG.Cart');
         $cart = new \Cart();
         $user_address = M('shop_useraddress');
         $item_order = M('shop_orders');
         $order_detail = M('order_detail');
         //生成订单号
         $dingdanhao = date("Y-m-dH-i-s");
         $dingdanhao = str_replace("-", "", $dingdanhao);
         $dingdanhao .= rand(1000, 9999);
         $time = time();
         //订单添加时间
         $address_options = I('post.address_options', '', 'intval');
         //地址  0:刚填的地址 大于0历史的地址
         $shipping_id = I('post.shipping_id', '', 'intval');
         //配送方式
         $postscript = I('post.postscript', '', 'trim');
         //卖家留言
         if (!empty($postscript)) {
             //卖家留言
             $data['note'] = $postscript;
         }
         //仅支持卖家包邮
         //if(empty($shipping_id)){//卖家包邮
         $data['freetype'] = 0;
         $data['order_sumPrice'] = $cart->getPrice();
         //} else{
         // $data['freetype']       = $shipping_id;
         // $data['freeprice']      = $this->getFree($shipping_id);//取到运费
         // $data['order_sumPrice'] = $cart->getPrice()+$this->getFree($shipping_id);
         //}
         $data['orderId'] = $dingdanhao;
         //订单号
         $data['add_time'] = $time;
         //添加时间
         $data['goods_sumPrice'] = $cart->getPrice();
         //商品总额
         $data['userId'] = $userinfo['id'];
         //用户ID
         if ($address_options == 0) {
             $consignee = I('post.consignee', '', 'trim');
             //真实姓名
             $sheng = I('post.sheng', '', 'trim');
             //省
             $shi = I('post.shi', '', 'trim');
             //市
             $qu = I('post.qu', '', 'trim');
             //区
             $address = I('post.address', '', 'trim');
             //详细地址
             $phone_mob = I('post.phone_mob', '', 'trim');
             //电话号码
             $save_address = I('post.save_address', '', 'trim');
             //是否保存地址
             $data['address_name'] = $consignee;
             //收货人姓名
             $data['mobile'] = $phone_mob;
             //电话号码
             $data['address'] = $sheng . $shi . $qu . $address;
             //地址
             //自动保存地址进数据库
             if ($save_address) {
                 $add_address['consignee'] = $consignee;
                 $add_address['address'] = $address;
                 $add_address['mobile'] = $phone_mob;
                 $add_address['sheng'] = $sheng;
                 $add_address['shi'] = $shi;
                 $add_address['qu'] = $qu;
                 $user_address->add($add_address);
             }
         } else {
             $userId = $userinfo['id'];
             //提取用户地址
             $address = $user_address->where("uid='{$userId}'")->find($address_options);
             //取到地址
             $data['address_name'] = $address['consignee'];
             //收货人姓名
             $data['mobile'] = $address['mobile'];
             //电话号码
             $data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
             //地址
         }
         $orderid = $item_order->add($data);
         //添加订单
         if ($orderid) {
             $orders['orderId'] = $dingdanhao;
             $item_goods = M('docunment_shop');
             foreach ($_SESSION['cart'] as $item) {
                 //减少库存
                 $item_goods->where(array('id' => $item['id']))->setDec('shop_goods_stock', $item['num']);
                 //$item_goods->where('id ='.$item['id'])->setDec('goods_stock',$item['num']);
                 $orders['itemId'] = $item['id'];
                 //商品ID
                 $orders['title'] = $item['name'];
                 //商品名称
                 $orders['img'] = $item['img'];
                 //商品图片
                 $orders['price'] = $item['price'];
                 //商品价格
                 $orders['quantity'] = $item['num'];
                 //购买数量
                 $order_detail->add($orders);
             }
             $cart->clear();
             //清空购物车
             $this->assign('orderid', $orderid);
             //订单ID
             $this->assign('dingdanhao', $dingdanhao);
             //订单号
             $this->assign('order_sumPrice', $data['order_sumPrice']);
         } else {
             $this->error('生成订单失败!');
         }
     } else {
         if (isset($_GET['orderId'])) {
             $item_order = M('shop_orders');
             //订单号
             $userId = $userinfo['id'];
             //去除单号  安全后缀  空格
             $orderId = str_replace(' ', '', str_replace('.html?showwxpaytitle=1', '', $_GET['orderId']));
             $orders = $item_order->where("userId='{$userId}' and orderId='{$orderId}'")->find();
             if (!is_array($orders)) {
                 $this->error('该订单不存在');
             }
             Wxpay::get_prepay_id();
             if (empty($orders['supportmetho'])) {
                 //是否已有支付方式
                 $this->assign('orderid', $orders['id']);
                 //订单ID
                 $this->assign('dingdanhao', $orders['orderId']);
                 //订单号
                 $this->assign('order_sumPrice', $orders['order_sumPrice']);
             } else {
                 //微信支付
                 $alipay = M('alipay')->find();
                 echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>";
                 die;
             }
         }
     }
     $this->book_menu($userinfo);
     //选择支付方式  货到付款  微信支付
     if (!empty($wxpay_config['hb_dh_diyong'])) {
         $time = time();
         $map['hb_star'] = array('lt', $time);
         $map['hb_end'] = array('gt', $time);
         $map['status'] = 1;
         $map['userid'] = $userinfo['id'];
         $hblist = M('wxpay_userhongbao')->where($map)->select();
         $this->assign('hblist', $hblist);
     }
     $this->assign('paylist', $wxpay_config['Allow_type']);
     $this->display();
 }
Ejemplo n.º 6
0
 function get_clear($id = null)
 {
     $ids = (array) $this->in('id', null);
     $id and $ids[] = $id;
     if ($ids) {
         foreach ($ids as $id) {
             Cart::clear($id);
         }
     } else {
         Cart::clear();
     }
     $this->status($ids ? 'remove' : 'clear', array('title' => ''));
     return $this->back(Cart::has() ? route('vanemart::cart') : '/');
 }
Ejemplo n.º 7
0
 public function pay()
 {
     if (IS_POST && count($_SESSION['cart']) > 0) {
         $_SESSION['end'] = 0;
         import('Think.ORG.Cart');
         // 导入分页类
         $cart = new Cart();
         $user_address = M('user_address');
         $item_order = M('item_order');
         $order_detail = M('order_detail');
         $item_goods = M('item');
         $this->visitor->info['id'];
         //用户ID
         $this->visitor->info['username'];
         //用户账号
         //生成订单号
         $dingdanhao = date("Y-m-dH-i-s");
         $dingdanhao = str_replace("-", "", $dingdanhao);
         $dingdanhao .= rand(1000, 2000);
         $time = time();
         //订单添加时间
         $address_options = $this->_post('address_options', 'intval');
         //地址  0:刚填的地址 大于0历史的地址
         $shipping_id = $this->_post('shipping_id', 'intval');
         //配送方式
         $postscript = $this->_post('postscript', 'trim');
         //卖家留言
         if (!empty($postscript)) {
             $data['note'] = $postscript;
         }
         if (empty($shipping_id)) {
             $data['freetype'] = 0;
             $data['order_sumPrice'] = $cart->getPrice();
         } else {
             $data['freetype'] = $shipping_id;
             $data['freeprice'] = $this->getFree($shipping_id);
             //取到运费
             $data['order_sumPrice'] = $cart->getPrice() + $this->getFree($shipping_id);
             //echo $cart->getPrice()+$this->getFree($shipping_id);exit;
         }
         $data['orderId'] = $dingdanhao;
         //订单号
         $data['add_time'] = $time;
         //添加时间
         $data['goods_sumPrice'] = $cart->getPrice();
         //商品总额
         $data['color'] = $cart->getColor();
         //商品颜色
         //$data['userId']=$this->visitor->info['id'];//用户ID
         //$data['userName']=$this->visitor->info['username'];//用户名
         $data['userId'] = '123';
         //用户ID
         $data['userName'] = '******';
         //用户名
         if ($address_options == 0) {
             $consignee = $this->_post('consignee', 'trim');
             //真实姓名
             $sheng = $this->_post('sheng', 'trim');
             //省
             $shi = $this->_post('shi', 'trim');
             //市
             $qu = $this->_post('qu', 'trim');
             //区
             $address = $this->_post('address', 'trim');
             //详细地址
             $phone_mob = $this->_post('phone_mob', 'trim');
             //电话号码
             $save_address = $this->_post('save_address', 'trim');
             //是否保存地址
             $data['address_name'] = $consignee;
             //收货人姓名
             $data['mobile'] = $phone_mob;
             //电话号码
             $data['address'] = $sheng . $shi . $qu . $address;
             //地址
             if ($save_address) {
                 $add_address['uid'] = $this->visitor->info['id'];
                 $add_address['consignee'] = $consignee;
                 $add_address['address'] = $address;
                 $add_address['mobile'] = $phone_mob;
                 $add_address['sheng'] = $sheng;
                 $add_address['shi'] = $shi;
                 $add_address['qu'] = $qu;
                 $user_address->data($add_address)->add();
             }
         } else {
             $userId = $this->visitor->info['id'];
             $address = $user_address->where("uid='{$userId}'")->find($address_options);
             //取到地址
             $data['address_name'] = $address['consignee'];
             //收货人姓名
             $data['mobile'] = $address['mobile'];
             //电话号码
             $data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
             //地址
         }
         if ($orderid = $item_order->data($data)->add()) {
             $orders['orderId'] = $dingdanhao;
             foreach ($_SESSION['cart'] as $item) {
                 $item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
                 $orders['itemId'] = $item['id'];
                 //商品ID
                 $orders['title'] = $item['name'];
                 //商品名称
                 $orders['img'] = $item['img'];
                 //商品图片
                 $orders['price'] = $item['price'];
                 //商品价格
                 $orders['quantity'] = $item['num'];
                 //购买数量
                 $orders['color'] = $item['color'];
                 //购买数量
                 $order_detail->data($orders)->add();
             }
             $cart->clear();
             //清空购物车
             $payment_id = $_POST['payment_id'];
             $item_order = M('item_order')->where(" orderId='{$dingdanhao}'")->find();
             !$item_order && $this->_404();
             $title = '新订单' . $data['goods_sumPrice'] . '元';
             $content = '您收到订单' . $dingdanhao . ',商品' . $orders['quantity'] . '件,总价格' . $data['goods_sumPrice'] . '元。购买者姓名:' . $consignee . '。收货人地址:' . $data['address'];
             $tips_data = M('setting')->where(" name='tips'")->find();
             $emails = unserialize($tips_data['data']);
             if ($payment_id == 2) {
                 $data['status'] = 2;
                 $data['supportmetho'] = 2;
                 $data['support_time'] = time();
                 if (M('item_order')->where("orderId='{$dingdanhao}'")->data($data)->save()) {
                     $_SESSION['end'] = 1;
                     if ($emails && !empty($emails)) {
                         $mailer = mailer::get_instance();
                         $mailer->send($emails, $title, $content);
                     }
                     $this->redirect('Shopcart/index');
                 } else {
                     $this->error('操作失败!');
                 }
             } elseif ($payment_id == 1) {
                 $data['supportmetho'] = 1;
                 $userId = $this->visitor->info['id'];
                 if (M('item_order')->where("and orderId='{$dingdanhao}'")->data($data)->save()) {
                     $alipay = M('alipay')->find();
                     echo "<script>location.href='api/wapalipay/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $dingdanhao . "&WIDsubject=" . $dingdanhao . "&WIDtotal_fee=" . $item_order['order_sumPrice'] . "'</script>";
                 } else {
                     $this->error('操作失败!');
                 }
             } else {
                 $this->error('操作失败!');
             }
             $this->assign('orderid', $orderid);
             //订单ID
             $this->assign('dingdanhao', $dingdanhao);
             //订单号
             $this->assign('order_sumPrice', $data['order_sumPrice']);
         } else {
             $this->error('生成订单失败!');
         }
     } else {
         if (isset($_GET['orderId'])) {
             $item_order = M('item_order');
             $orderId = $_GET['orderId'];
             //订单号
             $userId = $this->visitor->info['id'];
             $orders = $item_order->where("userId='{$userId}' and orderId='{$orderId}'")->find();
             if (!is_array($orders)) {
                 $this->_404();
             }
             if (empty($orders['supportmetho'])) {
                 $this->assign('orderid', $orders['id']);
                 //订单ID
                 $this->assign('dingdanhao', $orders['orderId']);
                 //订单号
                 $this->assign('order_sumPrice', $orders['order_sumPrice']);
             } else {
                 $alipay = M('alipay')->find();
                 echo "<script>location.href='api/wapalipay/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>";
                 exit;
             }
         } else {
             $this->redirect('Index/index?m=Item&a=index&id=127');
         }
     }
     $this->display();
 }
Ejemplo n.º 8
0
 public function pay()
 {
     if (IS_POST && count($_SESSION['cart']) > 0) {
         import('Think.ORG.Cart');
         // 导入分页类
         $cart = new Cart();
         $user_address = M('user_address');
         $item_order = M('item_order');
         $order_detail = M('order_detail');
         $item_goods = M('item');
         $this->visitor->info['id'];
         //用户ID
         $this->visitor->info['username'];
         //用户账号
         //生成订单号
         $dingdanhao = date("Y-m-dH-i-s");
         $dingdanhao = str_replace("-", "", $dingdanhao);
         $dingdanhao .= rand(1000, 2000);
         $time = time();
         //订单添加时间
         $address_options = $this->_post('address_options', 'intval');
         //地址  0:刚填的地址 大于0历史的地址
         $shipping_id = $this->_post('shipping_id', 'intval');
         //配送方式
         $postscript = $this->_post('postscript', 'trim');
         //卖家留言
         if (!empty($postscript)) {
             //卖家留言
             $data['note'] = $postscript;
         }
         if (empty($shipping_id)) {
             //卖家包邮
             $data['freetype'] = 0;
             $data['order_sumPrice'] = $cart->getPrice();
         } else {
             $data['freetype'] = $shipping_id;
             $data['freeprice'] = $this->getFree($shipping_id);
             //取到运费
             $data['order_sumPrice'] = $cart->getPrice() + $this->getFree($shipping_id);
             //echo $cart->getPrice()+$this->getFree($shipping_id);exit;
         }
         $data['orderId'] = $dingdanhao;
         //订单号
         $data['add_time'] = $time;
         //添加时间
         $data['goods_sumPrice'] = $cart->getPrice();
         //商品总额
         $data['userId'] = $this->visitor->info['id'];
         //用户ID
         $data['userName'] = $this->visitor->info['username'];
         //用户名
         if ($address_options == 0) {
             $consignee = $this->_post('consignee', 'trim');
             //真实姓名
             $sheng = $this->_post('sheng', 'trim');
             //省
             $shi = $this->_post('shi', 'trim');
             //市
             $qu = $this->_post('qu', 'trim');
             //区
             $address = $this->_post('address', 'trim');
             //详细地址
             $phone_mob = $this->_post('phone_mob', 'trim');
             //电话号码
             $save_address = $this->_post('save_address', 'trim');
             //是否保存地址
             $data['address_name'] = $consignee;
             //收货人姓名
             $data['mobile'] = $phone_mob;
             //电话号码
             $data['address'] = $sheng . $shi . $qu . $address;
             //地址
             if ($save_address) {
                 //保存地址
                 $add_address['uid'] = $this->visitor->info['id'];
                 $add_address['consignee'] = $consignee;
                 $add_address['address'] = $address;
                 $add_address['mobile'] = $phone_mob;
                 $add_address['sheng'] = $sheng;
                 $add_address['shi'] = $shi;
                 $add_address['qu'] = $qu;
                 $user_address->data($add_address)->add();
             }
         } else {
             $address = $user_address->where('uid=' . $this->visitor->info['id'])->find($address_options);
             //取到地址
             $data['address_name'] = $address['consignee'];
             //收货人姓名
             $data['mobile'] = $address['mobile'];
             //电话号码
             $data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
             //地址
         }
         if ($orderid = $item_order->data($data)->add()) {
             //添加订单成功
             $orders['orderId'] = $dingdanhao;
             foreach ($_SESSION['cart'] as $item) {
                 $item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
                 $orders['itemId'] = $item['id'];
                 //商品ID
                 $orders['title'] = $item['name'];
                 //商品名称
                 $orders['img'] = $item['img'];
                 //商品图片
                 $orders['price'] = $item['price'];
                 //商品价格
                 $orders['quantity'] = $item['num'];
                 //购买数量
                 $order_detail->data($orders)->add();
             }
             $cart->clear();
             //清空购物车
             $this->assign('orderid', $orderid);
             //订单ID
             $this->assign('dingdanhao', $dingdanhao);
             //订单号
             $this->assign('order_sumPrice', $data['order_sumPrice']);
         } else {
             $this->error('生成订单失败!');
         }
     } elseif (isset($_GET['orderId'])) {
         $item_order = M('item_order');
         $orderId = $_GET['orderId'];
         //订单号
         $orders = $item_order->where('userId=' . $this->visitor->info['id'] . ' and orderId=' . $orderId)->find();
         if (!is_array($orders)) {
             $this->_404();
         }
         if (empty($orders['supportmetho'])) {
             //是否已有支付方式
             $this->assign('orderid', $orders['id']);
             //订单ID
             $this->assign('dingdanhao', $orders['orderId']);
             //订单号
             $this->assign('order_sumPrice', $orders['order_sumPrice']);
         } else {
             $alipay = M('alipay')->find();
             echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>";
             exit;
         }
     } else {
         $this->redirect('user/index');
     }
     $this->display();
 }
Ejemplo n.º 9
0
 public function pay()
 {
     //取商家token值,取不到则默认为空
     $tokenTall = $this->getTokenTall();
     $this->assign('tokenTall', $tokenTall);
     //header("content-Type: text/html; charset=Utf-8");
     //dump($_POST);exit;
     if (IS_POST && count($_SESSION['cart']) > 0) {
         import('Think.ORG.Cart');
         // 导入购物车类
         $cart = new Cart();
         $user_address = M('user_address');
         $item_order = M('item_order');
         $order_detail = M('order_detail');
         $item_goods = M('item');
         $this->visitor->info['id'];
         //用户ID
         $this->visitor->info['username'];
         //用户账号
         //收货地址begin
         $addr = array();
         $address_options = $this->_post('address_options', 'intval');
         //0:刚填的地址;大于0:历史地址
         if ($address_options == 0) {
             $consignee = $this->_post('consignee', 'trim');
             //真实姓名
             $sheng = $this->_post('sheng', 'trim');
             //省
             $shi = $this->_post('shi', 'trim');
             //市
             $qu = $this->_post('qu', 'trim');
             //区
             $address = $this->_post('address', 'trim');
             //详细地址
             $phone_mob = $this->_post('phone_mob', 'trim');
             //电话号码
             $save_address = $this->_post('save_address', 'trim');
             //是否保存地址
             $addr['address_name'] = $consignee;
             //收货人姓名
             $addr['mobile'] = $phone_mob;
             //电话号码
             $addr['address'] = $sheng . $shi . $qu . $address;
             //地址
             if ($save_address) {
                 $add_address['uid'] = $this->visitor->info['id'];
                 $add_address['consignee'] = $consignee;
                 $add_address['address'] = $address;
                 $add_address['mobile'] = $phone_mob;
                 $add_address['sheng'] = $sheng;
                 $add_address['shi'] = $shi;
                 $add_address['qu'] = $qu;
                 $user_address->data($add_address)->add();
             }
         } else {
             $address = $user_address->where("uid='" . $this->visitor->info['id'] . "'")->find($address_options);
             //取到地址
             $addr['address_name'] = $address['consignee'];
             //收货人姓名
             $addr['mobile'] = $address['mobile'];
             //电话号码
             $addr['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
             //地址
         }
         //收货地址end
         //把购物车的商品按商家分组
         $result = $this->cart_by_group();
         //header("content-Type: text/html; charset=Utf-8");
         //dump($result);exit;
         $all_order_arr = array();
         //所有生成的订单单号集合
         $all_order_price = 0;
         //所有生成的订单总额
         //按店铺生成订单
         foreach ($result as $key => $value) {
             $data = array();
             //生成订单号
             $dingdanhao = date("Y-m-dH-i-s");
             $dingdanhao = str_replace("-", "", $dingdanhao);
             $dingdanhao .= rand(1000, 2000);
             $time = time();
             //订单添加时间
             $goods_sum = 0;
             foreach ($value['item'] as $items) {
                 $goods_sum = $goods_sum + floatval($items['price']) * floatval($items['num']);
             }
             $free_sum = 0;
             $freetype = $this->_post('free_' . $key, 'intval');
             //配送方式
             if ($freetype == 0) {
                 //卖家包邮
                 $free_sum = 0;
             } else {
                 $free_sum = $this->_post('freefee_' . $key, 'intval');
                 //取到运费
             }
             $postscript = '';
             //卖家留言
             $postscript = $this->_post('mymsg_' . $key, 'trim');
             //卖家留言
             $data['orderId'] = $dingdanhao;
             //订单号
             $data['add_time'] = $time;
             //添加时间
             $data['goods_sumPrice'] = $goods_sum;
             //商品总额
             $data['order_sumPrice'] = $goods_sum + $free_sum;
             //订单总额
             $data['note'] = $postscript;
             $data['userId'] = $this->visitor->info['id'];
             //用户ID
             $data['userName'] = $this->visitor->info['username'];
             //用户名
             $data['address_name'] = $addr['address_name'];
             //收货人姓名
             $data['mobile'] = $addr['mobile'];
             //电话号码
             $data['address'] = $addr['address'];
             //地址
             $data['freetype'] = $freetype;
             //配送方式
             $data['freeprice'] = $free_sum;
             //配送金额
             $data['tokenTall'] = $key;
             $all_order_arr[] = $dingdanhao;
             $all_order_price = $all_order_price + $goods_sum + $free_sum;
             if ($orderid = $item_order->data($data)->add()) {
                 $orders = array();
                 $orders['orderId'] = $dingdanhao;
                 foreach ($value['item'] as $item) {
                     $item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
                     $orders['itemId'] = $item['id'];
                     //商品ID
                     $orders['title'] = $item['name'];
                     //商品名称
                     $orders['img'] = $item['img'];
                     //商品图片
                     $orders['price'] = $item['price'];
                     //商品价格
                     $orders['quantity'] = $item['num'];
                     //购买数量
                     $orders['size'] = $item['size'];
                     //购买大小
                     $orders['color'] = $item['color'];
                     //购买颜色
                     $order_detail->data($orders)->add();
                     //添加订单明细
                 }
             } else {
                 $this->error('生成订单失败!');
             }
         }
         $cart->clear();
         //清空购物车
         //$this->assign('orderid',$orderid);//订单ID
         //$this->assign('dingdanhao',$dingdanhao);//订单号
         //$this->assign('order_sumPrice',$data['order_sumPrice']);
         //header("content-Type: text/html; charset=Utf-8");
         //dump(implode(',', $all_order_arr));exit;
         //重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。
         $merge = date("Y-m-dH-i-s");
         $merge = str_replace("-", "", $merge);
         $merge .= rand(1000, 2000);
         foreach ($all_order_arr as $order) {
             $data1['orderid'] = $order;
             $data1['mergeid'] = $merge;
             M('order_merge')->where("orderid='" . $order . "'")->delete();
             M('order_merge')->data($data1)->add();
         }
         //$this->assign('dingdanhao', implode(',', $all_order_arr));//所有订单
         //所有订单号
         $this->assign('allorderid', $all_order_arr);
         //支付号
         $this->assign('dingdanhao', $merge);
         $this->assign('order_sumPrice', $all_order_price);
         //总金额
         $this->assign('order_zhifu', '0');
     } else {
         if (isset($_GET['orderId'])) {
             $item_order = M('item_order');
             $orderId = $_GET['orderId'];
             //订单号
             $orders = $item_order->where("userId='" . $this->visitor->info['id'] . "' and orderId='" . $orderId . "'")->find();
             if (!is_array($orders)) {
                 $this->_404();
             }
             $this->assign('orderid', $orders['id']);
             //订单ID
             /* 
              * 不能这么干,应该发起查询,如果没有支付,则再进行支付。by zcb
             //重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。
             $merge = date("Y-m-dH-i-s");
             $merge = str_replace("-","",$merge);
             $merge .= rand(1000,2000);
             M('order_merge')->where("orderid='".$orderId."'")->delete();
             M('order_merge')->data(array('orderid'=>$orderId, 'mergeid'=>$merge))->add();
             */
             $merge = M('order_merge')->where(array('orderid' => $orderId))->find();
             //支付号
             $this->assign('dingdanhao', $merge['mergeid']);
             //订单号
             $this->assign('allorderid', array($orderId));
             $this->assign('order_sumPrice', $orders['order_sumPrice']);
             $this->assign('order_exist', '1');
             if (empty($orders['supportmetho'])) {
                 $this->assign('order_zhifu', '0');
             } else {
                 //$alipay=M('alipay')->find();
                 //echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=".$alipay['alipayname']."&WIDout_trade_no=".$orderId."&WIDsubject=".$orderId."&WIDtotal_fee=".$orders['order_sumPrice']."'</script>";
                 //exit;
                 $this->assign('order_zhifu', $orders['supportmetho']);
             }
         } else {
             $this->redirect('user/index', array('tokenTall' => $tokenTall));
         }
     }
     $this->display();
 }
Ejemplo n.º 10
0
 public function action_clear_cart()
 {
     $items = \Cart::items();
     $order = null;
     if (is_numeric(\Session::get('order.id'))) {
         $order = \Order\Model_Order::find_one_by_id(\Session::get('order.id'));
     }
     if ($order) {
         $order->delete();
     }
     if ($items) {
         foreach ($items as $item) {
             // Find artworks
             if ($unique_id = $item->get('unique_id')) {
                 if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id, 'order_id' => \Session::get('order.id'))))) {
                     $ysi = \Yousendit\Base::forge();
                     // Artworks (update, delete)
                     foreach ($artworks as $artwork) {
                         // Remove deleted artwork
                         if ($artwork->file_id) {
                             $ysi->delete_artwork($artwork->file_id);
                         }
                     }
                 }
             }
         }
     }
     // Delete order & cart session
     \Session::delete('order.id');
     \Cart::clear();
     \Messages::info('Your cart is empty.');
     if (\Input::is_ajax()) {
         echo \Messages::display();
         exit;
     } else {
         \Response::redirect(\Input::referrer(\Uri::create('order/checkout/address')));
     }
 }
Ejemplo n.º 11
0
function loadApi($action)
{
    switch ($action) {
        case 'htmlpopupdata':
            $htmlData = Cart::htmlPopupData();
            $data = json_encode(array('data' => $htmlData));
            return $data;
            break;
        case 'add_product':
            if (!Request::has(array('productid', 'quantity'))) {
                throw new Exception("Product not valid.");
            }
            try {
                Cart::addProduct(Request::get('productid'), Request::get('quantity'));
                $data = json_encode(array('error' => 'no', 'message' => 'Add product success.'));
                return $data;
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'remove_product':
            if (!Request::has('productid')) {
                throw new Exception("Product not valid.");
            }
            Cart::removeProduct(Request::get('productid'));
            $data = json_encode(array('error' => 'no', 'message' => 'Remove product success.'));
            return $data;
            break;
        case 'remove_coupon':
            if (!Request::has('code')) {
                throw new Exception("Coupon not valid.");
            }
            Cart::removeCoupon();
            $data = json_encode(array('error' => 'no', 'message' => 'Remove coupon success.'));
            return $data;
            break;
        case 'remove_voucher':
            if (!Request::has('code')) {
                throw new Exception("Voucher not valid.");
            }
            Cart::removeVoucher();
            $data = json_encode(array('error' => 'no', 'message' => 'Remove voucher success.'));
            return $data;
            break;
        case 'clear':
            Cart::clear();
            $data = json_encode(array('error' => 'no', 'message' => 'Clear cart success.'));
            return $data;
            break;
        case 'add_coupon':
            if (!Request::has('code')) {
                throw new Exception("Coupon code not valid.");
            }
            try {
                Cart::addCoupon(Request::get('code'));
                $data = json_encode(array('error' => 'no', 'message' => 'Add coupon success.'));
                return $data;
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'add_voucher':
            if (!Request::has('code')) {
                throw new Exception("Voucher code not valid.");
            }
            try {
                Cart::addVoucher(Request::get('code'));
                $data = json_encode(array('error' => 'no', 'message' => 'Add voucher success.'));
                return $data;
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
    }
}
Ejemplo n.º 12
0
 public function actionCheckout()
 {
     // get data from Cart
     $productInCart = Cart::getProduct();
     if ($productInCart == false) {
         header("Location: /");
     }
     // get categories list for left menu
     $categories = Category::getCategoriesList();
     // get total price
     $productsId = array_keys($productInCart);
     $products = Product::getProductByIds($productsId);
     $totalPrice = Cart::getTotalPrice($products);
     // get count of products
     $totalQuantity = Cart::countItems();
     // fields for form
     $userName = false;
     $userPhone = false;
     $userComment = false;
     // the status of a successful checkout
     $result = false;
     // check is user guest
     if (!User::isGuest()) {
         // if user not guest get his info from database
         $userId = User::checkLogged();
         $user = User::getUserById($userId);
         $userName = $user['name'];
     } else {
         // if user is guest -- the forms field will be empty
         $userId = false;
     }
     if (isset($_POST['submit'])) {
         // read form data
         $userName = $_POST['userName'];
         $userPhone = $_POST['userPhone'];
         $userComment = $_POST['userComment'];
         // data validation
         $errors = false;
         if (!User::checkName($userName)) {
             $errors[] = 'Wrong input name';
         }
         if (!User::checkPhoneNumber($userPhone)) {
             $errors[] = 'Wrong intup Phone number';
         }
         if ($errors == false) {
             // data input correctly
             // save order in database
             $result = Order::save($userName, $userPhone, $userComment, $userId, $productInCart);
             // send email
             if ($result) {
                 // $adminEmail = '*****@*****.**';
                 // $message = 'future link on admin part';
                 // $subject = 'New order';
                 // mail($adminEmail, $subject, $message);
                 // clear the cart
                 Cart::clear();
             }
         }
     }
     require_once ROOT . '/views/cart/checkout.php';
     return true;
 }
Ejemplo n.º 13
0
require_once ROOT . DS . 'controllers' . DS . 'cart.class.php';
require_once ROOT . DS . 'controllers' . DS . 'cookie.class.php';
require_once 'db.class.php';
$cart = new Cart();
$db = new DB($db_host, $db_user, $db_password, $db_name);
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
if ($action == 'add') {
    $id = $_GET['id'];
    $cart->addProduct($id);
    header('Location: index.php');
} elseif ($action == 'delete') {
    $id = $_GET['id'];
    $cart->deleteProduct($id);
    header('Location: cart.php');
} elseif ($action == 'clear') {
    $cart->clear();
    header('Location: cart.php');
} else {
    if ($cart->isEmpty()) {
        echo "Cart is empty";
    } else {
        $id_sql = $cart->getProducts(true);
        $sql = "SELECT * FROM books WHERE id IN ({$id_sql})";
        $books = $db->query($sql);
        echo "My cart: <br>";
        foreach ($books as $book) {
            echo "<b>{$book['title']}</b>  <a href='cart.php?action=delete&id={$book['id']}'>Delete from cart</a> <br>";
        }
    }
}
?>
Ejemplo n.º 14
0
 public function actionClear()
 {
     Cart::clear();
 }
Ejemplo n.º 15
0
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time_radio = IFilter::act(IReq::get('accept_time_radio'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $is_tax = IFilter::act(IReq::get('is_tax'), 'int');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = intval(IReq::get('direct_gid'));
     $num = intval(IReq::get('direct_num'));
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = intval(IReq::get('direct_active_id'));
     $tourist = IReq::get('tourist');
     //游客方式购物
     $order_no = block::createOrderNum();
     $order_type = 0;
     $is_protectPrice = IFilter::act(IReq::get('protect_price'));
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //活动特殊处理
     if ($promo != '' && $active_id != '') {
         //团购
         if ($promo == 'groupon') {
             $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}");
             //此团购还存在已经报名但是未付款的情况
             if (regiment::hasJoined($active_id, $hashId) == true) {
                 IError::show(403, '您已经参加过此次团购,请先完成支付');
                 exit;
             }
             //团购已经达到限定的人数
             if (regiment::isFull($active_id) == true) {
                 IError::show(403, '此团购的参加人数已满');
                 exit;
             }
             $order_type = 1;
             //团购开始报名
             $joinUserId = $user_id ? $user_id : null;
             $resultData = regiment::join($active_id, $joinUserId);
             $is_success = '';
             if ($resultData['flag'] == true) {
                 $regimentRelationObj = new IModel('regiment_user_relation');
                 $regimentRelationObj->setData(array('order_no' => $order_no));
                 $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
             }
             if ($is_success == '' || $resultData['flag'] == false) {
                 $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
                 IError::show(403, $errorMsg);
                 exit;
             }
         } else {
             if ($promo == 'time') {
                 $order_type = 2;
             }
         }
     }
     //付款方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id, 'type');
     if ($deliveryRow['type'] == 0 && $payment == 0) {
         IError::show(403, '请选择支付方式');
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         }
     }
     $countSumObj = new CountSum();
     //直接购买商品方式
     if ($type != '' && $gid != 0) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     $sum_r = $goodsResult['sum'];
     $proReduce_r = $goodsResult['proReduce'];
     $reduce_r = $goodsResult['reduce'];
     $final_sum_r = $goodsResult['final_sum'];
     $freeFreight_r = $goodsResult['freeFreight'];
     $point_r = $goodsResult['point'];
     $exp_r = $goodsResult['exp'];
     //计算运费$deliveryPrice和保价$protect_price
     $deliveryList = Delivery::getDelivery($province, $goodsResult['weight'], $final_sum_r);
     $deliveryPrice = $deliveryList[$delivery_id]['price'];
     if ($is_protectPrice == null) {
         $protect_price = 0;
         $if_insured = 0;
     } else {
         $protect_price = $deliveryList[$delivery_id]['protect_price'];
         $if_insured = 1;
     }
     if ($freeFreight_r == true) {
         $deliveryPrice_r = 0;
     } else {
         $deliveryPrice_r = $deliveryPrice;
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $ticket_value = $ticketRow['value'];
                 $reduce_r += $ticket_value;
                 $final_sum_r -= $ticket_value;
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //获取税率$tax
     if ($is_tax == 1) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $tax_per = isset($site_config['tax']) ? $site_config['tax'] : 0;
         $tax = $final_sum_r * ($tax_per / 100);
     } else {
         $tax = 0;
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $payment_fee = 0;
         $paymentType = 0;
         $paymentNote = '';
     } else {
         //计算支付手续费
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,poundage,poundage_type,name,note');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
         $paymentNote = $paymentRow['note'];
         if ($paymentRow['poundage_type'] == 1) {
             $payment_fee = ($final_sum_r + $tax + $deliveryPrice_r + $protect_price) * ($paymentRow['poundage'] / 100);
         } else {
             $payment_fee = $paymentRow['poundage'];
         }
     }
     //最终订单金额计算
     $order_amount = $final_sum_r + $deliveryPrice_r + $payment_fee + $tax + $protect_price;
     $order_amount = $order_amount <= 0 ? 0 : round($order_amount, 2);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'status' => 1, 'pay_status' => 0, 'distribution_status' => 0, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'invoice' => $is_tax, 'postscript' => $order_message, 'invoice_title' => $tax_title, 'accept_time' => $accept_time, 'exp' => $exp_r, 'point' => $point_r, 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $deliveryPrice, 'real_freight' => $deliveryPrice_r, 'pay_fee' => $payment_fee, 'taxes' => $tax, 'promotions' => $proReduce_r + $reduce_r, 'order_amount' => $order_amount, 'if_insured' => $if_insured, 'insured' => $protect_price);
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderGoodsObj = new IModel('order_goods');
     $goodsArray = array('order_id' => $this->order_id);
     $findType = array('goods' => 'goodsList', 'product' => 'productList');
     foreach ($findType as $key => $list) {
         if (isset($goodsResult[$list]) && count($goodsResult[$list]) > 0) {
             foreach ($goodsResult[$list] as $k => $val) {
                 //拼接商品名称和规格数据
                 $specArray = array('name' => $val['name'], 'value' => '');
                 if ($key == 'product') {
                     $goodsArray['product_id'] = $val['id'];
                     $goodsArray['goods_id'] = $val['goods_id'];
                     $spec = block::show_spec($val['spec_array']);
                     foreach ($spec as $skey => $svalue) {
                         $specArray['value'] .= $skey . ':' . $svalue . ' , ';
                     }
                 } else {
                     $goodsArray['goods_id'] = $val['id'];
                     $goodsArray['product_id'] = 0;
                 }
                 $specArray = serialize($specArray);
                 $goodsArray['goods_price'] = $val['sell_price'];
                 $goodsArray['real_price'] = $val['sell_price'] - $val['reduce'];
                 $goodsArray['goods_nums'] = $val['count'];
                 $goodsArray['goods_weight'] = $val['weight'];
                 $goodsArray['goods_array'] = $specArray;
                 $orderGoodsObj->setData($goodsArray);
                 $orderGoodsObj->add();
             }
         }
     }
     //更改购买商品的库存数量
     Block::updateStore($this->order_id, 'reduce');
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
         $addressRow = $addressObj->getObj('user_id = ' . $user_id);
         if (empty($addressRow)) {
             $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile);
             $addressObj->setData($addressData);
             $addressObj->add();
         } else {
             //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
             $radio_address = intval(IReq::get('radio_address'));
             if ($radio_address != 0) {
                 $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
                 if (empty($addressDefRow)) {
                     $addressData = array('default' => 1);
                     $addressObj->setData($addressData);
                     $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
                 }
             }
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment_fee = $payment_fee;
     $this->payment = $paymentName;
     $this->delivery = $deliveryList[$delivery_id]['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     $this->paymentType = $paymentType;
     $this->paymentNote = $paymentNote;
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = payment::updateOrder($dataArray['order_no']);
         if ($order_id != '') {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->redirect('cart3');
     }
 }
Ejemplo n.º 16
0
 protected function autoresponder($user, $order)
 {
     $settings = \Config::load('autoresponder.db');
     // Send autoresponder
     $autoresponder = \Autoresponder\Autoresponder::forge();
     $autoresponder->user_id = $user->id;
     $autoresponder->view_user = '******';
     $autoresponder->view_admin = 'order';
     $content['content'] = $order;
     $content['subject'] = 'Order confirmation from ' . $settings['website'];
     $autoresponder->autoresponder_user($content);
     $content['subject'] = 'Order confirmation from ' . $settings['website'] . ' for Admin';
     $autoresponder->autoresponder_admin($content, $settings['email_address']);
     //\Config::get('auto_response_emails.order_emails'));
     if ($autoresponder->send()) {
         \Messages::success('Thank You. Your order has been submitted and copy of this order has been sent to your email address.');
     } else {
         \Messages::success('Thank You. Your order has been submitted.');
     }
     // Delete order & cart session
     \Session::delete('order.id');
     \Session::delete('paypal.token');
     \Cart::clear();
     \Response::redirect(\Uri::create('order/checkout/complete/' . $order->id));
 }
Ejemplo n.º 17
0
 protected function autoresponder($user, $order)
 {
     // Send autoresponder
     $autoresponder = \Autoresponder\Autoresponder::forge();
     $autoresponder->user_id = $user->id;
     $autoresponder->view_user = '******';
     $autoresponder->view_admin = 'order';
     $content['content'] = $order;
     $content['subject'] = 'User Autoresponder Order';
     $autoresponder->autoresponder_user($content);
     $content['subject'] = 'Autoresponder Order for Admin';
     $autoresponder->autoresponder_admin($content, \Config::get('auto_response_emails.order_emails'));
     if ($autoresponder->send()) {
         \Messages::success('Thank You. Your order has been submitted and copy of this order has been sent to your email address.');
     } else {
         \Messages::success('Thank You. Your order has been submitted.');
     }
     // Delete order & cart session
     \Session::delete('order.id');
     \Cart::clear();
     \Response::redirect(\Uri::create('order/checkout/complete/' . $order->id));
 }
Ejemplo n.º 18
0
 /**
  * 生成订单
  */
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $taxes = IFilter::act(IReq::get('taxes'), 'float');
     $insured = IFilter::act(IReq::get('insured'), 'float');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = IFilter::act(IReq::get('direct_gid'), 'int');
     $num = IFilter::act(IReq::get('direct_num'), 'int');
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = IFilter::act(IReq::get('direct_active_id'), 'int');
     $order_no = Order_Class::createOrderNum();
     $order_type = 0;
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //活动特殊处理
     if ($promo != '' && $active_id != '') {
         //团购
         if ($promo == 'groupon') {
             $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}");
             //此团购还存在已经报名但是未付款的情况
             if (regiment::hasJoined($active_id, $hashId) == true) {
                 IError::show(403, '您已经参加过此次团购,请先完成支付');
                 exit;
             }
             //团购已经达到限定的人数
             if (regiment::isFull($active_id) == true) {
                 IError::show(403, '此团购的参加人数已满');
                 exit;
             }
             $order_type = 1;
             //团购开始报名
             $joinUserId = $user_id ? $user_id : null;
             $resultData = regiment::join($active_id, $joinUserId);
             $is_success = '';
             if ($resultData['flag'] == true) {
                 $regimentRelationObj = new IModel('regiment_user_relation');
                 $regimentRelationObj->setData(array('order_no' => $order_no));
                 $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
             }
             if ($is_success == '' || $resultData['flag'] == false) {
                 $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
                 IError::show(403, $errorMsg);
                 exit;
             }
         } else {
             if ($promo == 'time') {
                 $order_type = 2;
             }
         }
     }
     //付款方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id);
     if ($deliveryRow['type'] == 0 && $payment == 0) {
         IError::show(403, '请选择支付方式');
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         }
     }
     //计算费用
     $countSumObj = new CountSum();
     //直接购买商品方式
     if ($type != '' && $gid != 0) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $paymentType = 0;
     } else {
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
     }
     //最终订单金额计算
     $orderData = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $province, $delivery_id, $payment, $goodsResult['freeFreight'], $insured, $taxes);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $orderData['deliveryOrigPrice'], 'real_freight' => $orderData['deliveryPrice'], 'pay_fee' => $orderData['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $taxes, 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'] + (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'order_amount' => $orderData['orderAmountPrice'] - (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'if_insured' => $insured ? 1 : 0, 'insured' => $insured);
     $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount'];
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderInstance = new Order_Class();
     $orderInstance->insertOrderGoods($this->order_id, $goodsResult);
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
         $addressRow = $addressObj->getObj('user_id = ' . $user_id);
         if (empty($addressRow)) {
             $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile);
             $addressObj->setData($addressData);
             $addressObj->add();
         } else {
             //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
             $radio_address = intval(IReq::get('radio_address'));
             if ($radio_address != 0) {
                 $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
                 if (empty($addressDefRow)) {
                     $addressData = array('default' => 1);
                     $addressObj->setData($addressData);
                     $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
                 }
             }
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment = $paymentName;
     $this->paymentType = $paymentType;
     $this->delivery = $deliveryRow['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = Order_Class::updateOrderStatus($dataArray['order_no']);
         if ($order_id != '') {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->setRenderData($dataArray);
         $this->redirect('cart3');
     }
 }
Ejemplo n.º 19
0
 function clearCart()
 {
     $cartObj = new Cart();
     $cartObj->clear();
     $this->redirect('cart');
 }
Ejemplo n.º 20
0
|
*/
Route::get('/', function () {
    return view('site.index');
});
Route::group(['namespace' => 'Api'], function () {
    Route::group(['prefix' => 'api'], function () {
        Route::controller("product/{h?}", "ProductController");
    });
});
Route::get('/casex', function () {
    return dd(\Cart::all());
});
Route::get('/case0', function () {
    \Cart::add(['id' => 1231, 'name' => 'Zapatillas', 'quantity' => 1, 'price' => 100, 'tax' => '10%']);
});
Route::get('/case1', function () {
    \Cart::addCoupon(['id' => "ABC123", 'name' => "10% en Zapatillas", 'code' => "ABC123", 'discount' => "-20%"]);
    return "se ha agregado un cupon al carro";
});
Route::get('/case2', function () {
    \Cart::clear();
    return "se ha borrado la sesion";
});
Route::get('/case3', function () {
    \Cart::addOtherCharge(['id' => 12213, 'name' => 'shipping', 'amount' => 100]);
    return "se ha agregado el cargo";
});
Route::get('/case4', function () {
    return dd(\Cart::total(true));
});
Ejemplo n.º 21
0
 public function postCheckout(Request $request)
 {
     \DB::beginTransaction();
     $customer = Customer::create($request->all());
     $order = $customer->orders()->create(['quantity' => \Cart::getTotalQuantity(), 'total' => \Cart::getTotal(), 'shipped' => false]);
     foreach (\Cart::getContent() as $cart) {
         $order->details()->create(['deal_id' => $cart->id, 'quantity' => $cart->quantity, 'price' => $cart->price]);
     }
     $order->push();
     $customer->push();
     \DB::commit();
     \Cart::clear();
     return view('frontend.checkout.done')->with('categories', Category::all());
 }
Ejemplo n.º 22
0
 public function cartClear()
 {
     $user_id = (int) $_POST['user_id'];
     $cart = new Cart($user_id);
     $cart->clear($user_id);
 }
Ejemplo n.º 23
0
 public static function onFinishAction()
 {
     $cartObj = new Cart();
     $cartObj->clear();
 }
Ejemplo n.º 24
0
 /**
  * The function posts Order.
  * 
  * @access private
  * @param object $Order The Order to save.
  * @param object $Cart The Cart object to clear items.
  * @return string The JSON response.
  */
 private function postOrder(Order $Order, Cart $Cart = null)
 {
     $error = array();
     $Order->setPost($_POST);
     $Custom = $Order->getCustom();
     $Address = $Order->getAddress();
     if ($Order->Type == Order::STANDARD && (!$Address->Name || !$Address->Phone) || $Order->Type == Order::CUSTOM && (!$Custom->Name || !$Custom->Email) || $Order->Type == Order::PRODUCT && (!$Address->Name || !$Address->Phone)) {
         $error[] = 'Заполните все обязательные поля';
     } else {
         if ($Order->Type != Order::CUSTOM && !Error::check($Address->Email, 'email')) {
             $error[] = 'Введите корректный E-mail';
         } else {
             if ($Order->save()) {
                 if (!empty($_FILES['file']['tmp_name'])) {
                     if (File::upload($Order, $_FILES['file'])) {
                         $Order->save();
                     }
                 }
                 if ($Cart) {
                     $Cart->clear();
                     $Cart->save();
                 }
                 $Email = new Email_Order($Order);
                 if (!$Email->send()) {
                     $error[] = 'Ошибка отправки сообщения';
                 }
             } else {
                 $error[] = 'Ошибка записи данных';
             }
         }
     }
     $response = array('result' => count($error) ? 0 : 1);
     $response['posted'] = 1;
     $response['msg'] = implode("\n", $error);
     return $this->outputJSON($response);
 }
Ejemplo n.º 25
0
 function add_cart()
 {
     $shop_site = get_post_value('shop_site');
     $image_url = get_post_value('image_url');
     $product = get_post_value('product');
     $product_url = get_post_value('product_url');
     $product_id = get_post_value('product_id');
     $shop_url = get_post_value('shop_url');
     $shop_username = get_post_value('shop_username');
     $qty = get_post_value('qty');
     $sku = get_post_value('sku');
     $sku_name = get_post_value('sku_name');
     $price = get_post_value('price_cn');
     $shop_id = get_post_value('shop_id');
     if (!Login::verifyLogin()) {
         // var_dump($cart_array);
         if (empty($_COOKIE['shop_cart_info'])) {
             //   $cart_info[0]['shop_site'] = $shop_site;
             $cart_info[0]['image_url'] = $image_url;
             //   $cart_info[0]['product'] = $product;
             //   $cart_info[0]['product_url'] = $product_url;
             $cart_info[0]['product_id'] = $product_id;
             // $cart_info[0]['shop_url'] = $shop_url;
             //$cart_info[0]['shop_username'] = $shop_username;
             $cart_info[0]['qty'] = $qty;
             $cart_info[0]['sku'] = $sku;
             $cart_info[0]['sku_name'] = $sku_name;
             // $cart_info[0]['price'] = $price;
             //$cart_info[0]['shop_id'] = $shop_id;
             setcookie("shop_cart_info", serialize($cart_info), time() + 3600 * 24, '/');
             $this->assign('message', 2);
             $this->setReturnType('message');
         } else {
             $cart_array = unserialize(stripslashes($_COOKIE['shop_cart_info']));
             $ar_keys = array_keys($cart_array);
             rsort($ar_keys);
             $max_array_keyid = $ar_keys[0] + 1;
             //  $cur_cart_array[$max_array_keyid]['shop_site'] = $shop_site;
             $cart_array[$max_array_keyid]['image_url'] = $image_url;
             // $cur_cart_array[$max_array_keyid]['product'] = $product;
             // $cur_cart_array[$max_array_keyid]['product_url'] = $product_url;
             $cart_array[$max_array_keyid]['product_id'] = $product_id;
             // $cur_cart_array[$max_array_keyid]['shop_url'] = $shop_url;
             // $cur_cart_array[$max_array_keyid]['shop_username'] = $shop_username;
             $cart_array[$max_array_keyid]['qty'] = $qty;
             $cart_array[$max_array_keyid]['sku'] = $sku;
             $cart_array[$max_array_keyid]['sku_name'] = $sku_name;
             //  $cur_cart_array[$max_array_keyid]['price'] = $price;
             // $cur_cart_array[$max_array_keyid]['shop_id'] = $shop_id;
             setcookie("shop_cart_info", serialize($cart_array), time() + 3600 * 24, '/');
             $this->assign('message', 2);
             $this->setReturnType('message');
         }
     } else {
         if (isset($_SESSION['user_id'])) {
             $user_id = $_SESSION['user_id'];
         } else {
             $this->assign('message', 0);
             $this->setReturnType('message');
             exit;
         }
         // 保存数据
         $m = new Cart();
         $field = array('created' => date('Y-m-d H:i:s', time()), 'user_id' => $user_id, 'shop_username' => $shop_username, 'shop_url' => $shop_url, 'product_id' => $product_id, 'product_url' => $product_url, 'shop_url' => $shop_url, 'shop_username' => $shop_username, 'qty' => $qty, 'sku' => $sku, 'sku_name' => $sku_name, 'status' => '10000', 'product' => $product, 'image_url' => $image_url, 'price' => $price, 'shop_id' => $shop_id, 'shop_site' => $shop_site);
         $m->clear();
         $m->setField($field);
         $m->setTable('vcb_cart');
         $data = $m->insert();
         if (!empty($data)) {
             $data = 1;
         } else {
             $data = 0;
         }
         $this->assign('message', 1);
         $this->setReturnType('message');
     }
 }
Ejemplo n.º 26
0
 /**
  * Action для страницы "Оформление покупки"
  */
 public function actionCheckout()
 {
     $productsInCart = Cart::getProducts();
     if ($productsInCart == false) {
         header("Location: /");
     }
     $categories = Category::getCategoriesList();
     // Находим общую стоимость
     $productsIds = array_keys($productsInCart);
     $products = Product::getProdustsByIds($productsIds);
     $totalPrice = Cart::getTotalPrice($products);
     // Количество товаров
     $totalQuantity = Cart::countItems();
     $userName = false;
     $userPhone = false;
     $userComment = false;
     $result = false;
     if (!User::isGuest()) {
         // Если пользователь не гость
         // Получаем информацию о пользователе из БД
         $userId = User::checkLogged();
         $user = User::getUserById($userId);
         $userName = $user['name'];
     } else {
         // Если гость, поля формы останутся пустыми
         $userId = false;
     }
     if (isset($_POST['submit'])) {
         $userName = $_POST['userName'];
         $userPhone = $_POST['userPhone'];
         $userComment = $_POST['userComment'];
         // Флаг ошибок
         $errors = false;
         if (!User::checkName($userName)) {
             $errors[] = 'Неправильное имя';
         }
         if (!User::checkPhone($userPhone)) {
             $errors[] = 'Неправильный телефон';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Сохраняем заказ в базе данных
             $result = Order::save($userName, $userPhone, $userComment, $userId, $productsInCart);
             if ($result) {
                 // Если заказ успешно сохранен
                 // Оповещаем администратора о новом заказе по почте
                 $adminEmail = '*****@*****.**';
                 $message = '<a href="localhost/admin/orders">Список заказов</a>';
                 $subject = 'Новый заказ!';
                 mail($adminEmail, $subject, $message);
                 // Очищаем корзину
                 Cart::clear();
             }
         }
     }
     // Подключаем вид
     require_once ROOT . '/views/cart/checkout.php';
     return true;
 }