public function doRemove($id) { $book = Cart::get($id); Cart::remove($id); session([$book->id => null]); return redirect('/cart'); }
/** * Handle the event. * * @return void */ public function handle() { if (Cart::instance(auth()->id())->count(false) == 0) { } else { Cart::store(auth()->id()); } }
/** * @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')); }
/** * Prepare global variables. * @return array */ public static function globalData() { if (!Auth::check()) { $rows = null; $cart = null; $grandTotal = null; } else { $rows = Cart::instance(auth()->id())->count(false); $cart = Cart::instance(auth()->id())->content(); $grandTotal = Cart::instance(auth()->id())->total(); } $data = array('menu' => self::getMenuData(self::$parent_id), 'header' => Setting::findOrFail(1), 'rows' => $rows, 'cart' => $cart, 'grand_total' => $grandTotal, 'currencies' => Currency::all()); return $data; }
/** * 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 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'; } }
public function doLogout() { session(['user' => null]); foreach (Cart::content() as $row) { session([$row->id => null]); } Cart::destroy(); return redirect('/'); }
/** * Remove all items from the cart */ public function testClear() { $this->call('GET', '/cart/add/1'); $this->call('GET', '/cart/add/2'); $this->assertEquals(2, count(Cart::content())); $this->call('GET', '/cart/clear'); $this->assertRedirectedToRoute('cart.index'); $this->assertEquals(0, count(Cart::content())); }
/** * Removes a coupon from the list * * @param string $couponName * @return Response */ public function remove($couponName) { try { Cart::removeCoupon(strtolower($couponName)); } catch (Exceptions\CouponNotFoundException $e) { // Do nothing } return redirect()->route('cart.index'); }
/** * Returns the biggest discount */ public function testDiscount() { Cart::add(1, 'ITEM1', 1, '100'); Cart::addCoupon('TEST20', 10); Cart::addCoupon('TEST10', 20); Cart::addCoupon('TEST50', 50); Cart::addCoupon('TEST40', 30); $this->assertEquals(50, Cart::discount()); }
/** * Add item to cart * * @return void */ public function testRemoveItem() { $this->call('GET', '/coupon/add/TEST20'); $this->assertEquals(1, count(Cart::coupons())); $this->call('GET', '/coupon/remove/TEST20'); //$this->assertRedirectedToRoute('cart.index'); $this->assertEquals(0, count(Cart::coupons())); $this->call('GET', '/coupon/remove/TEST20'); $this->assertRedirectedToRoute('cart.index'); }
/** * Prepare order and customer data for database. * @param Request $request */ public function createOrder($request) { $cart = Cart::content(); $customer = $request->session()->all(); $customer['user_id'] = Auth::user()->id; $this->customer->create($customer); foreach ($cart as $item) { $this->order->create(['user_id' => Auth::user()->id, 'order_date' => Carbon::now(), 'product_id' => $item->id, 'quantity' => $item->qty, 'amount' => $item->subtotal, 'size' => $item->options->size, 'img' => $item->options->img, 'color' => $item->options->color]); } }
/** * Execute the command. * * @return string */ public function handle() { try { $cart = Cart::associate('Product', 'App\\Repositories'); $cart->add($this->product['id'], $this->product['name'], $this->product['quantity'], $this->product['price']); event(new ProductAddedToShoppingCart()); return $this->product['id']; } catch (Exception $e) { return $e->getMessage(); } }
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"); }
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()); }
/** * Execute the command. * */ public function handle() { Cart::remove($this->productId); event(new ProductRemovedFromShoppingCart()); }
public static function destroy() { Cart::instance('cart')->destroy(); }
/** * Display Check Out Landing Page * * @return Response */ public function index() { $cartItems = Cart::content()->toArray(); $cartTotal = Cart::total(); return view('checkout.index', compact('cartItems', 'cartTotal')); }
/** * 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')]); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { //adiciona o total de itens para que seja disponvel em toda as requisiçes. view()->share('totalItens', Cart::count()); return $next($request); }
public function cancelCart() { Cart::destroy(); return redirect('home')->with('success', 'Removed Cart!'); }
/** * Returns the cart * * @return mixed */ public function getCart() { $cart = Cart::instance('checkout'); return $cart->content(); }
private function updateOrder() { $this->order->total = Cart::total(); $this->order->save(); $this->deleteOrderItems(); $this->saveOrderItems(); $this->session->set(Auth::user()->id, $this->order); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy() { $cart = Cart::instance('cartoon'); $cart->destroy(); return Response::json(array('result' => true, 'cart' => $cart->content(), 'count' => $cart->count())); }
public function destroyBooking() { Cart::instance('booking')->destroy(); }
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'); }
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/'); }
/** * Handle the event. * * @param OrderWasPlaced $event * @return void */ public function handle(OrderWasPlaced $event) { $amount = $event->amount; $country = $event->order['country']; $vatRate = 25; $billing_id = $event->billing_id; $customerName = $event->order['first_name'] . ' ' . $event->order['last_name']; $customerAddress = $event->order['street']; $customerCity = $event->order['city']; $customerZip = $event->order['zip']; $customerEmail = $event->order['email']; $customerPhone = $event->order['phone']; $sendSms = $event->order['sendSms']; $checkUser = Auth::check() ? Auth::user()->id : 1; $products = Cart::content(); // Specific for saving an invoice $date = Carbon::now()->format('Y-m-d'); $lines = []; foreach ($products as $product) { $lines[] = ['productId' => $product->options->billys_product_id, 'unitPrice' => $product->price / 100]; } $billy = new BillysBilling(env('BILLYS_KEY')); $billyContact = $billy->makeBillyRequest('POST', '/contacts', ['contact' => ['type' => 'person', 'organizationId' => env('BILLY_ORGANIZATION'), 'name' => $customerName, 'countryId' => $country, 'street' => $customerAddress, 'cityText' => $customerCity, 'zipcodeText' => $customerZip, 'phone' => $customerPhone, 'isCustomer' => true]]); $billyContactId = $billyContact->body->contacts[0]->id; $order = Order::create(['amount' => $amount, 'vat_rate' => $vatRate, 'stripe_billing_id' => $billing_id, 'customer_name' => $customerName, 'customer_address' => $customerAddress, 'customer_city' => $customerCity, 'customer_country' => $country, 'customer_zip' => $customerZip, 'customer_email' => $customerEmail, 'customer_phone_number' => $customerPhone, 'sendSms' => $sendSms, 'user_id' => $checkUser, 'billys_contact_id' => $billyContactId]); $billyInvoice = $billy->makeBillyRequest('POST', '/invoices', ['invoice' => ['organizationId' => env('BILLY_ORGANIZATION'), 'contactId' => $billyContactId, 'entryDate' => $date, 'paymentTermsDays' => 5, 'state' => 'approved', 'sentState' => 'unsent', 'invoiceNo' => $order->id, 'currencyId' => 'DKK', 'lines' => $lines]]); $order->billys_invoice_id = $billyInvoice->body->invoices[0]->id; $order->save(); }