/** * Remove the specified resource from storage. * DELETE /carts/{id} * * @param int $id * @return Response */ public function destroy($id) { foreach (Cart::contents() as $item) { if ($item->id == $id) { $item->remove(); } } return 'true'; }
public function checkout(\App\Http\Requests\OrderFormRequest $request) { $data = \Request::all(); $data["items"] = \Cart::contents(); \Mail::send('orderemail', $data, function ($m) { $m->from('*****@*****.**', 'Your Application'); $m->to("*****@*****.**", "Admin")->subject('Your Reminder!'); }); Cart::destroy(); return redirect("cart"); }
function checkout() { // process cart items if (count(Cart::contents()) < 1) { return Redirect::to('order'); } $items = Cart::contents(); $invoice_id = DB::table('invoices')->insertGetId(array('user_id' => Auth::user()->id, 'due_date' => date('Y-m-d'), 'status' => 'Unpaid')); foreach ($items as $item) { // to ensure the shopping cart was not manipulated, we use the option directly, not from the price $option = ServiceOption::find($item->id); // build description string $description = $option->service->name . ' ' . $option->name . ' recurring every ' . $item->quantity . ' month(s)'; DB::table('invoice_items')->insert(array('invoice_id' => $invoice_id, 'description' => $description, 'unit_price' => $item->price)); } // push invoice to e-mail queue // empty the cart Cart::destroy(); return Redirect::to('order/thankyou'); }
/** * Setup the layout used by the controller. * * @return void */ public function __construct() { $this->beforeFilter(function () { // if((isset($_GET['access_id']) && $_GET['access_id'] == '5437edf7890') || isset($_COOKIE['access_id'])){ // if(!isset($_COOKIE['access_id'])){ // setcookie('access_id', $_GET['access_id'], time() + (3600)); // } View::share('catnav', Category::all()); View::share('cart_values', Cart::contents()); if (Auth::check()) { View::share('super', 0); View::share('vendor', 0); View::share('user', 0); View::share('user_id', Auth::user()->id); if (Auth::user()->isSuper) { View::share('super', 1); Session::put('user_status', 'super'); } elseif (Auth::user()->isVendor) { $notification = Order::where('vendor_id', '=', Auth::user()->id)->where('notification', '=', 1)->count(); View::share('vendor', 1); Session::put('notification', $notification); Session::put('user_status', 'vendor'); } else { View::share('user', 1); Session::put('user_status', 'user'); } View::share('guest_user', 0); } else { View::share('guest_user', 1); $notification = 0; Session::put('notification', $notification); Session::put('user_status', 'guest_user'); View::share('user_id', uniqid()); } // }else{ // return Redirect::to('http://www.Funfest.com'); // } }); }
public function getCart() { return View::make('store.cart')->with('products', Cart::contents()); }
public function PaymentSuccess($id) { $result = Session::get('result'); $user = Auth::user(); $participant = Participant::find($id); $player = $participant->player; $club = $participant->event->club; $title = 'League Together - ' . $participant->event->club->name . ' Events'; if (!$result) { return Redirect::action('AccountController@index'); } $param = array('transaction_id' => $result->transactionid, 'club' => $club->id, 'action_type' => $result->type); $payment = new Payment(); $transaction = json_decode(json_encode($payment->ask($param)), false); $items = Cart::contents(); // Clean the cart Cart::destroy(); return View::make('app.club.event.participant.checkout.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('transaction', $transaction->transaction); }
function gobuy() { self::is_login(); $info = M('member')->where('id=' . $_SESSION['dami_uid'])->find(); $this->assign('uinfo', $info); $iscart = $_REQUEST['iscart']; if ($iscart == 1) { import('ORG.Util.Cart'); $cart = new Cart(); $list = $cart->contents(); foreach ($list as $k => $v) { if ($v['id']) { $list[$k]['gtype'] = $v['option']['gtype']; $list[$k]['pic'] = $v['option']['pic']; } } } else { $list = array(0 => $_REQUEST); } if (!$list) { $this->error('您的购物为空,请先选择物品!'); exit; } $this->assign('list', $list); $this->display(); }
public function error($param, $id, $playerid) { setlocale(LC_MONETARY, "en_US"); $club = Club::Find($id); $user = Auth::user(); $player = Player::find($playerid); $query = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault, 'club' => $club->id); $payment = new Payment(); $vault = json_decode(json_encode($payment->ask($query)), false); //convert object to array $dt = json_decode(json_encode($param), false); //clean duplicates from array //$club = array_unique($club); //cart content $items = Cart::contents(); $data = array('data' => $dt, 'vault' => $vault, 'products' => $items, 'club' => $club, 'player' => $player); $mail = Mail::send('emails.receipt.error', $data, function ($message) use($user, $club) { $message->to($user->email, $user->profile->firstname . ' ' . $user->profile->lastname)->subject("Payment Declined | {$club->name}"); foreach ($club->users()->get() as $value) { $message->bcc($value->email, $club->name)->subject("Payment Declined - {$club->name}"); } }); return $mail; }
function ajax_cart_list() { import('ORG.Util.Cart'); $cart = new Cart(); $this->ajaxReturn($cart->contents(), '成功', 1); }
public function selectplayer() { $user = Auth::user(); $cart = Cart::contents(); // return $cart; return View::make('pages.public.select')->with('page_title', 'Select Player')->withPlayers($user->players)->with('products', $cart); }
public function getCart() { $vendor_id = ''; if (count(Cart::contents()) != 0) { $det = Cart::contents(); foreach ($det as $item) { $vendor_id = $item->vendor_id; } } $addon_items = ''; if ($vendor_id != '') { $addon_items = Addon::where('vendor_id', '=', $vendor_id)->get(); } return View::make('home.cart')->with('products', Cart::contents())->with('addon_items', $addon_items)->with('city_list', City::all()); }
private function getCountOfItems($excludeSets = FALSE, $currentWorkshopYearOnly = FALSE) { $count = array('CD' => array('count' => 0, 'sub_total_amt' => 0.0), 'DVD' => array('count' => 0, 'sub_total_amt' => 0.0), 'MP3' => array('count' => 0, 'sub_total_amt' => 0.0), 'SET' => array('count' => 0, 'sub_total_amt' => 0.0)); $currentWorkshopYear = Config::get('workshop.current_workshop_year'); // Use shopping cart, if still populated... if (Cart::contents()) { $cartContents = Cart::contents(); /* foreach ( $cartContents as $cartItem ) { if ( !$currentWorkshopYearOnly || ( $currentWorkshopYear && $cartItem->workshop_year == $currentWorkshopYear ) ) { if ( $cartItem->prod_type == 'SET' && !$excludeSets ) { if ( substr($cartItem->form_id, 0, 1) == 'C' ) { $count['CD']['count'] += $cartItem->unit_count * $cartItem->quantity; $count['CD']['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } else { $count[substr($cartItem->form_id, 0, 3)]['count'] += $cartItem->unit_count * $cartItem->quantity; $count[substr($cartItem->form_id, 0, 3)]['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } } else { $count[$cartItem->prod_type]['count'] += $cartItem->unit_count * $cartItem->quantity; $count[$cartItem->prod_type]['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } } } * */ // ... Otherwise, use order items. } else { if ($this->order_id > 0) { $orderItems = Order::find($this->order_id)->orderItems; $cartContents = OrdersController::convertOrderItemsToCartItems($orderItems); /* foreach ( $orderItems as $orderItem ) { $product = $orderItem->product(); if ( !$currentWorkshopYearOnly || ( $currentWorkshopYear && $product->workshop_year == $currentWorkshopYear ) ) { if ( $product->prod_type == 'SET' && !$excludeSets ) { if ( substr($product->form_id, 0, 1) == 'C' ) { $count['CD']['count'] += $product->unit_count * $orderItem->quantity; $count['CD']['sub_total_amt'] += $product->price * $orderItem->quantity; } else { $count[substr($product->form_id, 0, 3)]['count'] += $product->unit_count * $orderItem->quantity; $count[substr($product->form_id, 0, 3)]['sub_total_amt'] += $product->price * $orderItem->quantity; } } else { $count[$product->prod_type]['count'] += $product->unit_count * $orderItem->quantity; $count[$product->prod_type]['sub_total_amt'] += $product->price * $orderItem->quantity; } } } * */ } } foreach ($cartContents as $cartItem) { if (!$currentWorkshopYearOnly || $currentWorkshopYear && $cartItem->workshop_year == $currentWorkshopYear) { if ($cartItem->prod_type == 'SET' && !$excludeSets) { if (substr($cartItem->form_id, 0, 1) == 'C') { $count['CD']['count'] += $cartItem->unit_count * $cartItem->quantity; $count['CD']['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } else { $count[substr($cartItem->form_id, 0, 3)]['count'] += $cartItem->unit_count * $cartItem->quantity; $count[substr($cartItem->form_id, 0, 3)]['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } } else { $count[$cartItem->prod_type]['count'] += $cartItem->unit_count * $cartItem->quantity; $count[$cartItem->prod_type]['sub_total_amt'] += $cartItem->price * $cartItem->quantity; } } } return $count; }
public function PaymentSuccessTeam($club, $id) { $result = Session::get('result'); $user = Auth::user(); $team = Team::find($id); $club = Club::find($club); $title = 'League Together - ' . $club->name . ' Teams'; if (!$result) { return Redirect::action('AccountController@index'); } /* $param = array( 'report_type' => 'customer_vault', 'customer_vault_id' => $user->profile->customer_vault, 'club' => $club->id ); $payment = new Payment; $vault = $payment->ask($param);*/ //get transaction data from CF $param = array('transaction_id' => $result->transactionid, 'club' => $club->id, 'action_type' => $result->type); $payment = new Payment(); $transaction = json_decode(json_encode($payment->ask($param)), false); $items = Cart::contents(); // Clean the cart Cart::destroy(); return View::make('app.public.club.team.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('transaction', $transaction->transaction); }
public function showCart() { $cartContents = Cart::contents(); $this->layout->contents = View::make('products.show-cart', compact('cartContents'))->with(array('orderVerification' => FALSE)); }