/**
  * Remove all items from the cart
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $post = $request->all();
     $errors = [];
     if ($request->method() == 'POST') {
         $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'street_name' => 'required', 'city' => 'required', 'country' => 'required', 'zipcode' => 'required']);
         // If everything is ok
         if (count($validator->errors()->all()) == 0) {
             Order::addOrder($post, Cart::total(), Cart::discount(), Cart::content());
             Cart::clearCoupons();
             Cart::destroy();
             return redirect()->route('checkout.order');
         }
         $errors = $validator->errors()->all();
     }
     return view('checkout.index', ['products' => Cart::content(), 'total' => Cart::total(), 'discount' => Cart::discount(), 'total_with_discount' => Cart::totalWithDiscount(), 'post' => $post, 'errors' => $errors]);
 }
 public function checkOut(Request $request)
 {
     $address = \StringHelper::filterString($request->input('address'));
     $name = \StringHelper::filterString($request->input('name'));
     $content = \StringHelper::filterString($request->input('comments'));
     $phone = \StringHelper::filterString($request->input('phone'));
     $count = Cart::count();
     if ($phone != "" && $name != "" && $content != "" && $count > 0) {
         $order = new Order();
         $order->order_name = $name;
         $order->status = 1;
         $order->active = 1;
         $order->order_comment = $content;
         $order->order_address = $address;
         $order->order_phone = $phone;
         $order->save();
         $cart = Cart::content();
         foreach ($cart as $item) {
             $order_detail = new OrderDetail();
             $order_detail->dish_id = $item->id;
             $order_detail->dish_number = $item->qty;
             $order_detail->order_id = $order->id;
             $order_detail->save();
         }
         Cart::destroy();
         return Redirect::to(url('menu'))->with('message', 'Order Success !. You can continue buy now !');
     } else {
         return Redirect::to(url('checkout'))->with('message', 'Order Fail !. Something Wrong !');
     }
 }
Exemple #3
0
 public function doLogout()
 {
     session(['user' => null]);
     foreach (Cart::content() as $row) {
         session([$row->id => null]);
     }
     Cart::destroy();
     return redirect('/');
 }
 public function success(Buckaroo $buckaroo, Request $request)
 {
     $order = Order::find($buckaroo->invoice_nr(Request::all()));
     $order->payed = 1;
     $order->saveitems(Cart::content());
     $order->save();
     $event = Event::fire(new ItemsPurchasedEvent($order, Cart::content()));
     Session::forget('order');
     Cart::destroy();
     return view("shoppingcart.payment-success");
 }
 private function clear()
 {
     //clear cart
     Cart::destroy();
     //clear option
     $currentOption = Session::get('option');
     $currentOption['shi_add'] = false;
     $currentOption['pay_add'] = false;
     $currentOption['pay_med'] = false;
     $currentOption['conf'] = false;
     Session::forget('option');
     Session::put($currentOption);
     //clear pay_med
     Session::forget('pay_med');
 }
 public function postCheckout()
 {
     $tos = Cart::tos();
     $total = Cart::total();
     $input = array('order_date' => date('Y-m-d H:i:s'), 'total_tax' => $tos, 'total_purchase' => $total, 'order_status' => 'pending', 'name' => Input::get('name'), 'email' => Input::get('email'), 'no_tel' => Input::get('no_tel'), 'address' => Input::get('address'), 'city' => Input::get('city'), 'poskod' => Input::get('poskod'), 'state' => Input::get('state'));
     $order = Order::create($input);
     $formid = str_random();
     $cart_content = Cart::content();
     foreach ($cart_content as $cart) {
         $transaction = new Transaction();
         $transaction->product_id = $cart->id;
         $transaction->form_id = $formid;
         $transaction->qty = $cart->qty;
         $transaction->total_price = $cart->subtotal;
         $transaction->order_id = $order->id;
         $transaction->gambar_id = $cart->options->img_id;
         $transaction->color = $cart->options->color;
         $transaction->size = $cart->options->size;
         $transaction->category_id = $cart->options->cat;
         $transaction->save();
     }
     $ttr = Transaction::where('order_id', '=', $order->id);
     Cart::destroy();
     Session::forget('values');
     return redirect('store/thankyou/');
 }
 /**
  * Empty the Cart
  */
 public function destroy()
 {
     Cart::destroy();
 }
 /**
  *
  */
 public function ExecutePayment()
 {
     if (isset($_GET['success']) && $_GET['success'] == 'true') {
         // Get the payment Object by passing paymentId
         // payment id was previously stored in session in
         // CreatePaymentUsingPayPal.php
         $log = PayPalLog::find(Session::get('log_id'));
         $paymentId = $log->payment_id;
         //$payment = Paypalpayment::get($paymentId, $this->_apiContext);
         $payment = Payment::get($paymentId, $this->_apiContext);
         // PaymentExecution object includes information necessary
         // to execute a PayPal account payment.
         // The payer_id is added to the request query parameters
         // when the user is redirected from paypal back to your site
         $execution = Paypalpayment::PaymentExecution();
         $execution->setPayerId($_GET['PayerID']);
         //Execute the payment
         try {
             $order = $payment->execute($execution, $this->_apiContext)->toArray();
         } catch (\PPConnectionException $ex) {
             return "Exception: " . $ex->getMessage() . PHP_EOL;
             var_dump($ex->getData());
             exit(1);
         }
         $payer = $order['payer']['payer_info'];
         $log->state = $order['state'];
         $log->viewed = false;
         $log->paypal_id = $order['id'];
         $log->payer_email = $payer['email'];
         $log->payer_id = $payer['payer_id'];
         $log->payer_first_name = $payer['first_name'];
         $log->payer_last_name = $payer['last_name'];
         $log->shipping_address = json_encode($payer['shipping_address']);
         //note: you'll have to do foreach if you want multiple -v
         $log->item_list = json_encode($order['transactions'][0]);
         $log->total = $order['transactions'][0]['amount']['total'];
         $log->save();
         $cart = Cart::content();
         Cart::destroy();
         Flash::success('Payment Sucsess!');
         return view('cart.paypalReturn')->with('title', 'Payment Sucsess!')->with('address', $payer['shipping_address'])->with('cart', $cart)->with('log', $log);
     } else {
         echo "User cancelled payment.";
     }
     // Flash::success('Payment Sucsess!');
     // return redirect()->action('BooksController@show', [Session::get('bookId')]);
 }
Exemple #9
0
 public function cancelCart()
 {
     Cart::destroy();
     return redirect('home')->with('success', 'Removed Cart!');
 }
 /**
  * Remove all items from the cart
  *
  * @return Response
  */
 public function clear()
 {
     Cart::destroy();
     return redirect()->route('cart.index');
 }
 /**
  * Finaliza o pedido recebendo a mesa como parametro da requisicao
  * abre o pedido, salva, e salva os itens no pedido.
  * @param Request $request
  */
 public function finalizarCarrinho(Request $request)
 {
     $itens = Cart::content();
     $pedido = new Pedido();
     $pedido->mesa = $request->mesa;
     $pedido->total = Cart::total();
     if (Cart::count() != 0) {
         $pedido->save();
     } else {
         Flash::success("Por favor, adicione algum item no pedido!");
     }
     Log::info($pedido);
     //por enquanto vai ser assim, mas pense numa maneira melhor
     //de retornar o pedido criado.
     $pedidoAtual = Pedido::orderBy('id', 'desc')->first();
     $itensPedidos = array();
     foreach ($itens as $iten) {
         $itemPedido = new ItemPedido();
         $itemPedido->nome = $iten->name;
         $itemPedido->preco = $iten->price;
         $itemPedido->quantidade = $iten->qty;
         $itensPedidos[] = $itemPedido;
     }
     if (Cart::count() != 0) {
         $pedidoAtual->itens()->saveMany($itensPedidos);
         $pedidoAtual->save();
         Cart::destroy();
         Flash::success("Pedido finalizado!");
     } else {
         Flash::error("Por favor, adicione algum item no pedido!");
     }
     return redirect()->back();
 }