コード例 #1
0
 public function processOrder(Request $request)
 {
     $cartService = new cartService();
     $orderService = new orderService();
     $cart = $cartService->cartInformation();
     if (!$cart) {
         return view('client.cart.index');
     }
     $key = '__kacana_user_order__';
     $userOrder = \Session::get($key);
     $order = array();
     $order['email'] = isset($userOrder['email']) ? $userOrder['email'] : false;
     $order['name'] = $request->get('name', false);
     $order['street'] = $request->get('street', false);
     $order['city_id'] = $request->get('cityId', false);
     $order['district_id'] = $request->get('districtId', false);
     $order['ward_id'] = $request->get('wardId', '');
     $order['phone'] = $request->get('phone', false);
     $checkoutAddressId = $request->get('checkout-address-id', false);
     try {
         if ($checkoutAddressId && \Kacana\Util::isLoggedIn()) {
             $order = $cartService->processCartWithAddressId($this->_user->email, $checkoutAddressId);
         } else {
             $order = $cartService->processCart($order);
         }
         \Session::remove($key);
         return view('client.checkout.success', ['order' => $order]);
     } catch (\Exception $e) {
         if ($request->ajax()) {
             $result['error'] = $e->getMessage();
             return $result;
         } else {
             return view('errors.404', ['error_message' => $e]);
         }
     }
 }
コード例 #2
0
ファイル: CartController.php プロジェクト: kacana/kacana.com
 /**
  * @return \BladeView|bool|\Illuminate\View\View
  */
 public function showCart()
 {
     $cartService = new cartService();
     $cart = $cartService->cartInformation();
     $total = Cart::total();
     $cities = addressCityModel::lists('name', 'id');
     $ward = new addressWardModel();
     $wards = $ward->getItemsByCityId(CITY_ID_DEFAULT)->lists('name', 'id');
     return view('client.cart.index', array('cart' => $cart, 'total' => $total, 'cities' => $cities, 'wards' => $wards));
 }