示例#1
1
 /**
  * @return \Illuminate\View\View
  */
 protected function renderCart()
 {
     $cartItems = Cart::content()->toArray();
     $cartTotal = Cart::total();
     $checkoutAction = 'editCart';
     return view('pages.partials.shopping.cart', compact('cartItems', 'cartTotal', 'checkoutAction'));
 }
 /**
  * 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]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return view('cart', ['products' => Cart::content(), 'discount' => Cart::discount(), 'coupons' => Cart::coupons()->toArray(), 'total' => Cart::total(), 'total_with_discount' => Cart::totalWithDiscount()]);
 }
 public function getCartAjax()
 {
     $cart = Cart::content();
     $count = Cart::count();
     $total = Cart::total();
     return Response::json(array('content' => $cart, 'count' => $count, 'total' => $total));
 }
 public function index(Guard $auth, PedidoProduto $pedidoProduto)
 {
     if (\Auth::check()) {
         $idPagseguro = substr(md5(uniqid()), 0, 15);
         $dados = $auth->user();
         $produtosNoCarrinho = Cart::content();
         foreach ($produtosNoCarrinho as $produtoNoCarrinho) {
             $attributes = ['tb_pedidos_produto_cliente' => $dados->id, 'tb_pedidos_produto_id_pagseguro' => $idPagseguro, 'tb_pedidos_produto_quantidade' => $produtoNoCarrinho->qty, 'tb_pedidos_produto_subtotal' => $produtoNoCarrinho->subtotal, 'tb_pedidos_produto_id' => $produtoNoCarrinho->id, 'tb_pedidos_produto_data' => date('Y-m-d H:i:s')];
             $pedidoProduto->create($attributes);
         }
         $pagseguro = new Pagseguro($dados);
         $dadosPedidoPagseguro = ['id' => $idPagseguro, 'produto' => 'Vendas da Loja', 'preco' => Cart::total()];
         $pagseguro->setNome($dados->name);
         $pagseguro->setSobrenome('');
         $pagseguro->setEmail($dados->email);
         $pagseguro->setDdd('');
         $pagseguro->setTelefone('');
         $pagseguro->setIdReference($idPagseguro);
         $pagseguro->setItemAdd($dadosPedidoPagseguro);
         try {
             $url = $pagseguro->enviarPagseguro();
             echo $url;
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     } else {
         return 'logado';
     }
 }
 /**
  * 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();
 }
 /**
  * @return array
  */
 protected function getCartContent()
 {
     $cart = Cart::instance(auth()->user()->id)->content();
     $subtotal = Cart::total();
     $tax = 0.1 * $subtotal;
     $total = $subtotal + $tax;
     return array($cart, $subtotal, $tax, $total);
 }
 public function pay(Buckaroo $buckaroo)
 {
     /** Grab order and set payment method */
     $order = Session::get('order');
     $order->payment_method = Request::input('payment');
     $order->payment_total = Cart::total() + Config::get("site_settings.deliverycosts");
     /** Auth check and save */
     if (Auth::check()) {
         Auth::user()->orders()->save($order);
     } else {
         $order->save();
     }
     /** Fetch payment form and submit */
     return $buckaroo->fetchForm(['price' => $order->payment_total, 'payment_method' => Request::input('payment'), 'payment_bank' => Request::input('bank'), 'return_url' => 'http://local.werotterdam.com/shoppingcart/payment/success', 'invoice_nr' => $order->id]);
 }
 public function __construct()
 {
     View::share('pros', Product::take(8)->Where('status', 1)->orderBy('created_at', 'DESC')->get());
     View::share('customs', Product::take(8)->Where('type', 0)->orderBy('created_at', 'DESC')->get());
     View::share('products', Product::take(8)->Where('status', 1)->orderBy('created_at', 'DESC')->get());
     View::share('cus', Product::take(8)->Where('status', 1)->orderBy('created_at', 'ASC')->get());
     View::share('categories', Category::all());
     View::share('cart_content', Cart::content());
     View::share('count', Cart::count());
     View::share('total', Cart::total());
     View::share('set', Setting::find(1));
     View::share('tos', Cart::tos());
     View::share('transactions', Transaction::orderBy('created_at', 'desc')->paginate(10));
     View::share('settings', Setting::find(1));
     View::share('caty', Category::take(5)->orderBy('created_at', 'DESC')->get());
     View::share('payments', Payment::Where('status', 1)->get());
     View::share('customers', Customer::all());
     View::share('orders', Order::all());
     View::share('cat', Category::all());
     View::share('db', Product::take(6)->Where('status', 1)->orderBy('created_at', 'ASC')->get());
 }
示例#10
0
 public function checkout()
 {
     View::share(['title' => 'Checkout']);
     $cart = Cart::content();
     $total = Cart::total();
     $items = CartHelper::getDetailItem($cart);
     $city = Address::where('parent_id', 0)->get()->toArray();
     if ($total > 0) {
         return view('checkout.index')->with(['cart' => $cart, 'total' => $total, 'items' => $items, 'cities' => $city]);
     } else {
         return redirect()->action('FrontendController@index')->with('error', 'Nothing to checkout!');
     }
 }
示例#11
0
 function postLogin(LoginRequest $request)
 {
     //get Request
     $getDataRequest = $request->all();
     $data = array('name' => $getDataRequest['name'], 'password' => $getDataRequest['password']);
     $userInfo = User::where('name', $data['name'])->first()->toArray();
     //Check status?
     if ($userInfo['status'] == User::IN_ACTIVED_STATUS) {
         return redirect_errors("Account active yet!");
     }
     //Check password
     $password = md5($data['password'] . md5($userInfo['remember_token']));
     if ($password == $userInfo['password']) {
         //Add Session
         Authen::setUser($userInfo);
         //Check remember
         if (Input::get('remember')) {
             $permissions = Permission::where('name', 'like', $userInfo['role_id'] . '%')->get(['name']);
             $listPermission = [];
             foreach ($permissions as $per) {
                 $listPermission[] = $per['name'];
             }
             $data = $userInfo;
             $data['permission'] = $listPermission;
             Cache::put('user', $data, 6000);
         }
         //navigator page
         if ($userInfo['role_id'] == Role::SA_ROLE_ID || $userInfo['role_id'] == Role::AD_ROLE_ID) {
             return redirect()->action('BackendController@index');
         } elseif (Cart::total() > 0 && $userInfo['role_id'] == Role::CUS_ROLE_ID) {
             Session::forget('option');
             // is customer ensure to have shipping_add already
             Session::put('option', ['type' => 'logged', 'shi_add' => true, 'pay_add' => true, 'pay_med' => false, 'conf' => false]);
             return redirect()->action('FrontendController@checkout');
         } else {
             return redirect('home');
         }
     }
     return redirect_errors("Password Wrong!");
 }
 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/');
 }
示例#13
0
 public function total()
 {
     return Cart::total();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store()
 {
     if (Cart::count() < 1) {
         return redirect('/');
         exit(1);
     }
     $subtotal = (double) Cart::total();
     $shipping = 5.0;
     $payer = Paypalpayment::Payer();
     $payer->setPaymentMethod('paypal');
     // ### Items
     // These repersent the items in the cart
     $itemsArray = array();
     $cartItems = Cart::content()->toArray();
     foreach ($cartItems as $cartItem) {
         $item = Paypalpayment::Item();
         $item->setCurrency('EUR');
         $item->setName($cartItem['name']);
         $item->setPrice($cartItem['price']);
         $item->setQuantity((string) $cartItem['qty']);
         $item->setSku($cartItem['id']);
         $itemsArray[] = $item;
     }
     // add item to list
     $item_list = Paypalpayment::ItemList();
     $item_list->setItems($itemsArray);
     $details = Paypalpayment::Details();
     $details->setShipping($shipping)->setSubtotal($subtotal);
     // ### Amount
     // Lets you specify a payment amount.
     // You can also specify additional details
     // such as shipping, tax.
     $amount = Paypalpayment::Amount();
     $amount->setCurrency("EUR");
     $amount->setTotal($subtotal + $shipping);
     $amount->setDetails($details);
     $transaction = Paypalpayment::Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description');
     $redirect_urls = Paypalpayment::RedirectUrls();
     $redirect_urls->setReturnUrl(url('payment/ExecutePayment/?success=true'))->setCancelUrl(url('payment/ExecutePayment/?success=false'));
     $payment = Paypalpayment::Payment();
     $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
     Log::info("cool ->" . var_export($payment->toArray(), true));
     try {
         $payment->create($this->_apiContext);
     } catch (Exception $e) {
         if (\Config::get('app.debug')) {
             echo "Exception: " . $e->getMessage() . PHP_EOL;
             $err_data = json_decode($e->getData(), true);
             exit;
         } else {
             die('Some error occur, sorry for inconvenient');
         }
     }
     // add payment ID to session
     // Session::put('paypal_payment_id', $payment->getId());
     // Session::put('bookId', $request->bookId);
     if (isset($redirect_url)) {
         // redirect to paypald
         return redirect($redirect_url);
     }
     // ### Get redirect url
     // The API response provides the url that you must redirect
     // the buyer to. Retrieve the url from the $payment->getLinks()
     // method
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirectUrl = $link->getHref();
             break;
         }
     }
     // ### Redirect buyer to PayPal website
     // Save the payment id so that you can 'complete' the payment
     // once the buyer approves the payment and is redirected
     // back to your website.
     //
     // It is not a great idea to store the payment id
     // in the session. In a real world app, you may want to
     // store the payment id in a database.
     $pay_id = $payment->getId();
     // store the payment_id
     $log = PayPalLog::firstOrNew(array("payment_id" => $pay_id));
     $log->save();
     Session::put('log_id', $log->id);
     if (isset($redirectUrl)) {
         return redirect($redirectUrl);
         exit;
     }
 }
示例#15
0
 private function updateOrder()
 {
     $this->order->total = Cart::total();
     $this->order->save();
     $this->deleteOrderItems();
     $this->saveOrderItems();
     $this->session->set(Auth::user()->id, $this->order);
 }
 /**
  * Display Check Out Landing Page
  *
  * @return Response
  */
 public function index()
 {
     $cartItems = Cart::content()->toArray();
     $cartTotal = Cart::total();
     return view('checkout.index', compact('cartItems', 'cartTotal'));
 }