/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (\Cart::content()->isEmpty()) { return redirect('/'); } return $next($request); }
public function postAdd() { $rules = ['firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'address' => 'required|min:5', 'phone' => 'required|min:7']; if (!Auth::check()) { array_push($rules, ['email' => 'required|email|unique:users']); } $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to("checkout")->withErrors($validator)->withInput(Input::except('')); } else { if (Auth::check()) { $user = User::find(Auth::user()->id); } else { $user = new User(); $user->email = Input::get('email'); $password = str_random(10); $user->password = Hash::make($password); } $user->firstname = Input::get('firstname'); $user->lastname = Input::get('lastname'); $user->address = Input::get('address'); $user->phone = Input::get('phone'); if ($user->save()) { $role = Role::where('name', '=', 'Customer')->first(); if (!$user->hasRole("Customer")) { $user->roles()->attach($role->id); } $order = new Order(); $order->user_id = $user->id; $order->status_id = OrderStatus::where('title', '=', 'Новый')->first()->id; $order->comment = 'Телефон: <b>' . $user->phone . '</b><br>Адрес: <b>' . $user->address . '</b><br>Комментарий покупателя: ' . '<i>' . Input::get('comment') . '</i>'; if ($order->save()) { $cart = Cart::content(); foreach ($cart as $product) { $orderDetails = new OrderDetails(); $orderDetails->order_id = $order->id; $orderDetails->product_id = $product->id; $orderDetails->quantity = $product->qty; $orderDetails->price = $product->price; $orderDetails->save(); } } if (!Auth::check()) { Mail::send('mail.registration', ['firstname' => $user->firstname, 'login' => $user->email, 'password' => $password, 'setting' => Config::get('setting')], function ($message) { $message->to(Input::get('email'))->subject("Регистрация прошла успешно"); }); } $orderId = $order->id; Mail::send('mail.order', ['cart' => $cart, 'order' => $order, 'phone' => $user->phone, 'user' => $user->firstname . ' ' . $user->lastname], function ($message) use($orderId) { $message->to(Input::get('email'))->subject("Ваша заявка №{$orderId} принята"); }); Cart::destroy(); return Redirect::to("checkout/thanks/spasibo-vash-zakaz-prinyat")->with('successcart', 'ok', ['cart' => $cart]); } } }
public function cartTest() { // Cart::add(array('rowid'=>'w1','name'=>'Sugar','qty'=>2,'price'=>34000)); $c = Cart::content()->first(); dd($c->rowid); // $c=Cart::get('23576bd9795f9a68d28a6c0c4fbabf35'); // $c->lists('name'); // dd($c->price); //$cart = Cart::content(); // dd($c); }
public function productIdFromCart() { foreach (\Cart::content() as $product) { if ($product->qty > 1) { for ($x = 0; $x < $product->qty; $x++) { $ids[] = $product->id; } } else { $ids[] = $product->id; } } return $ids; }
public function ajaxCartRemove() { Cart::remove(Input::get('idRow')); $cartContentObj = Cart::content(); $cartContentArr = []; $cartCount = Cart::count(); foreach ($cartContentObj as $item) { $item->options['thumbnail'] = $item->ware->thumbnail; $item->options['slug'] = $item->ware->slug; $cartContentArr[] = $item; } return compact('cartContentArr', 'cartCount'); }
public function process() { $factura = new Factura(); $factura->usuario_id = Auth::user()->id; $factura->total = Cart::total(); foreach (Cart::content() as $item) { if (Item::find($item['id'])->stock == 0) { Session::flash('error', 'El item ' . $item['name'] . ' se ha agotado'); return Redirect::back(); } if (Item::find($item['id'])->stock - $item['qty'] < 0) { Session::flash('error', 'No hay suficiente stock del item ' . $item['name'] . ' para cubrir su pedido'); return Redirect::back(); } } if ($factura->save()) { foreach (Cart::content() as $item) { $detalle = new Detalle(); $detalle->factura_id = $factura->id; $detalle->item_id = $item['id']; $detalle->cantidad = $item['qty']; if ($detalle->save()) { $deduct = Item::find($item['id']); $deduct->stock -= $item['qty']; $deduct->save(); } else { Session::flash('error', 'Error al procesar'); return Redirect::back(); } } } else { Session::flash('error', 'Error al procesar'); return Redirect::back(); } Cart::destroy(); return Redirect::to('shop'); }
public function getCart() { return View::make('store.cart')->with('products', Cart::content()); }
function cartItems() { $items = []; $total = 0; foreach (\Cart::content() as $rowid => $item) { $product = \App\Product::find($item['id']); $items[] = ['id' => $item['id'], 'name' => $item['name'], 'options' => $item['options'], 'price' => $product->formatPrice($item['price']), 'qty' => $item['qty'], 'path' => $product->fullPath(), 'rowid' => $item['rowid'], 'subtotal' => $product->formatPrice($item['subtotal']), 'image' => $product->img()->first()]; $total += $item['subtotal']; } return json_encode(['items' => $items, 'total' => kalFormatPrice($total)]); }
Route::get('user/{id}/edit', ['uses' => 'UserController@edit']); Route::get('user/create', array('uses' => 'UserController@create')); Route::get('user', array('uses' => 'UserController@index')); Route::POST('user/store', array('uses' => 'UserController@store', 'as' => 'user.store')); Route::PUT('user/update', array('uses' => 'UserController@update', 'as' => 'user.update')); Route::delete('user/{id}', ['uses' => 'UserController@destroy']); Route::get('api/barang', array('uses' => 'BarangController@apiBarang')); Route::get('barang', array('uses' => 'BarangController@index')); Route::get('barang/create', array('uses' => 'BarangController@create')); Route::POST('barang/store', array('uses' => 'BarangController@store', 'as' => 'barang.store')); Route::get('api/getkodeBarang', ['uses' => 'BarangController@kodeBarang']); Route::DELETE('barang/delete/{id}', ['uses' => 'BarangController@destroy']); Route::get('barang/edit/{id}', ['uses' => 'BarangController@edit']); Route::PUT('barang/update/{id}', ['uses' => 'BarangController@update', 'as' => 'barang.update']); Route::get('barang/cart/', function () { $cart = Cart::content(); return View('barang.index', compact('cart')); }); Route::get('jual/cart/{id}', array('uses' => 'PenjualanController@destroy')); Route::get('api/cart', array('uses' => 'PenjualanController@apicart')); Route::POST('cart/jual', array('uses' => 'PenjualanController@addCart', 'as' => 'add.cart')); Route::post('laporan/penjualan', ['uses' => 'PenjualanController@getData']); Route::get('penjualan/laporan', ['uses' => 'PenjualanController@laporan']); Route::get('api/penjualan', ['uses' => 'PenjualanController@apiJual']); Route::get('penjualan', array('uses' => 'PenjualanController@index')); Route::get('penjualan/cart/delete/{id}', array('uses' => 'PenjualanController@deletecart')); Route::get('penjualan/cart', array('uses' => 'PenjualanController@cart')); Route::POST('penjualan/store', array('uses' => 'PenjualanController@store', 'as' => 'penjualan.store')); Route::get('barang/api', array('uses' => 'PenjualanController@apiBarang')); Route::get('pelanggan/api', array('uses' => 'PenjualanController@apiPelanggan')); Route::get('penjualan/struk', array('uses' => 'PenjualanController@faktur'));
| Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', 'HomeController@index'); Route::get('catalog/{path}', 'CategoriesController@index')->where('path', '(.*)?'); Route::get('katalog/{path}', 'CategoriesController@index')->where('path', '(.*)?'); Route::get('product/{path}', 'WaresController@index')->where('path', '(.*)?'); Route::any('ajax-cart', 'HomeController@ajaxCart'); Route::any('ajax-cart-remove', 'HomeController@ajaxCartRemove'); Route::get('cart-test', function () { $cartContentObj = Cart::content(); $cartContentArr = []; foreach ($cartContentObj as $item) { $item->thumbnail = $item->ware->thumbnail; $item->options['slug'] = 'sdfsd'; $cartContentArr[] = $item; } return $cartContentArr; }); Route::get('get-data', function () { $html = new Htmldom('http://dmtoys.com.ua/catalog/igrushki/interaktivnye-igrushki/angry-birds'); foreach ($html->find('#primary-menu-inner a') as $item) { echo $item->href . '<br>'; } }); Route::get('cart-destroy', function () {
public function viewCart() { $cart = Cart::content(); return View::make("cart", array("cart" => $cart)); }
public function checkoutStore() { // dd(Input::all()); $user = User::find(Auth::user()->id); $cart = Cart::content(); $rules = ['alamat' => 'required', 'pembayaran' => 'required', 'total' => 'required']; Validator::make($data = Input::all(), $rules); $data['user_id'] = $user->id; $data['telp'] = $user->telp; $data['email'] = $user->email; $order = Order::create($data); if (!$order) { return Redirect::back()->with('message', 'gagal menambahkan order ke database'); } $dataItems = []; foreach ($cart as $c) { $dataItems['order_id'] = $order->id; $dataItems['barang_id'] = $c->id; $dataItems['qty'] = $c->qty; $dataItems['price'] = $c->price; $dataItems['total'] = $c->price * $c->qty; $dataItems['berat'] = $c->options->berat * $c->qty; $dataItems['keterangan'] = $c->options->aroma; $orderItems = OrderItem::create($dataItems); if (!$orderItems) { return Redirect::back()->with('message', 'gagal menambahkan order item ke database'); } } Cart::destroy(); return Redirect::to('store')->with('message', 'Terima kasih, order anda berhasil masuk, silahkan tunggu untuk konfirmasi dari kami'); }
public function postPurchaseAndNewDir() { if (Cart::count() < 1) { Session::flash('danger', 'Error, no posee articulos en el carrito'); return Redirect::back(); } $input = Input::all(); $rules = array('email' => 'required|email', 'dir' => 'required'); $msg = array('required' => 'Campo requerido', 'email' => 'El campo debe ser un email'); $validator = Validator::make($input, $rules, $msg); if ($validator->fails()) { Redirect::back()->withError($validator)->withInput(); } $dir = new Dir(); $dir->user_id = Auth::user()->id; $dir->email = $input['email']; $dir->dir = $input['dir']; if ($dir->save()) { $fac = new Facturas(); $fac->user_id = Auth::user()->id; $fac->dir = $dir->id; if ($fac->save()) { foreach (Cart::content() as $c) { $misc = Misc::find($c->options['misc']); $misc->item_stock = $misc->item_stock - $c->qty; $misc->save(); $itemFac = new FacturaItem(); $itemFac->factura_id = $fac->id; $itemFac->item_id = $c->id; $itemFac->item_qty = $c->qty; $itemFac->item_talla = $c->options['talla']; $itemFac->item_color = $c->options['color']; $itemFac->item_precio = $c->price; $itemFac->save(); } Cart::destroy(); return Redirect::to('compra/procesar/' . $fac->id); } } }
public function index() { return View::make('shop.cart', ['setting' => Config::get('setting'), 'cart' => Cart::content()]); }
function createOrder() { $user_id = 0; if (Auth::user()->check()) { $user_id = Auth::user()->get()->id; } //Add billing address $billing_address = array(); if (Session::has('billing_address')) { $billing_address = Session::get('billing_address'); $billing_address['user_id'] = $user_id; $billing_address['country_name'] = Address::countryName($billing_address['country_a2']); if (!empty($billing_address['state_a2'])) { $billing_address['state_name'] = Address::stateName($billing_address['state_a2'], $billing_address['country_a2']); } $billing_address['is_billing'] = 1; $obj_billing_address = $this->createAddress($billing_address); } //add shipping address $shipping_address = array(); if (Session::has('shipping_address')) { $shipping_address = Session::get('shipping_address'); $shipping_address['user_id'] = $user_id; $shipping_address['country_name'] = Address::countryName($shipping_address['country_a2']); if (!empty($shipping_address['state_a2'])) { $shipping_address['state_name'] = Address::stateName($shipping_address['state_a2'], $shipping_address['country_a2']); } $shipping_address['is_billing'] = 0; $obj_shipping_address = $this->createAddress($shipping_address); } if (isset($obj_billing_address) && isset($obj_shipping_address)) { //Add to order table $cart_total = Cart::total(); $order = Order::create(["user_id" => $user_id, "sum_amount" => $cart_total, "billing_address_id" => $obj_billing_address->id, "shipping_address_id" => $obj_shipping_address->id, "status" => "New"]); //Add to order_details if ($order) { $cart_content = Cart::content(); foreach ($cart_content as $item) { $options = []; foreach ($item->options->options as $option) { $options[] = $option['key']; } $option_keys = implode(",", $options); $orderDetail = OrderDetail::create(["order_id" => $order->id, "image_id" => $item->id, "quantity" => $item->qty, "sell_price" => $item->price, "sum_amount" => $item->subtotal, "type" => $item->options->order_type, "size" => $item->options->size, "option" => $option_keys]); } //Clear session Cart::destroy(); Session::forget('billing_address'); Session::forget('shipping_address'); return $order; } } return false; }
public function getCarts() { $cart_content = Cart::content(); $cart_total = Cart::total(); $this->layout->content = View::make('frontend.order.index')->with(['cart_content' => $cart_content, 'cart_total' => $cart_total]); }
<div class="table-responsive"> <!-- Shop Products Table --> <table class="shop_table beta-shopping-cart-table" cellspacing="0"> <thead> <tr> <th class="product-name">Product</th> <th class="product-price">Price</th> <th class="product-status">Status</th> <th class="product-quantity">Qty.</th> <th class="product-subtotal">Total</th> <th class="product-remove">Remove</th> </tr> </thead> <tbody> <?php $content = Cart::content(); $total = Cart::total(); $itemHtml = ""; if ($content) { $x = 1; foreach ($content as $itemRow) { if (public_path()) { $source_folder = public_path() . '/uploads/images/'; $destination_folder = public_path() . '/uploads/images/'; } else { $source_folder = '/home/medicalng/public_html/uploads/images/'; $destination_folder = '/home/medicalng/public_html/uploads/images/'; } $product = Product::find($itemRow->id); $image_info = pathinfo($source_folder . $product->image); $image_extension = strtolower($image_info["extension"]);
/** * @return void */ public function testSearchItem() { $worker = \App::make('App\\Droit\\Shop\\Cart\\Worker\\CartWorkerInterface'); $oneproduct = factory(App\Droit\Shop\Product\Entities\Product::class)->make(); \Cart::instance('newInstance'); \Cart::add($oneproduct->id, $oneproduct->title, 1, $oneproduct->price, array('weight' => $oneproduct->weight)); $found = $worker->searchItem($oneproduct->id); $this->assertEquals($found[0], \Cart::content()->first()->rowid); }
public function saveGaji() { $cart = Cart::content(); foreach ($cart as $row) { $mg02 = new mg02(); $mg02->mk01_id = $row->options['idkaryawan']; $mg02->mg01_id = $row->name; $mg02->nilgj = $row->price; $mg02->save(); } Cart::destroy(); return Redirect::to("master/karyawan"); }
public function getMyCart() { $cart = Cart::content(); return View::make('reservations.cart', array('cartDetails' => $cart)); }
public function postAccommodationDetails() { // dd($bookedDetails); $items = Cart::count(false); if ($items) { $items_in_cart = Cart::content(); foreach ($items_in_cart as $data) { $roomBooked_id = $data->id; $branch_id = $data->name; $price_for_room = $data->price; $customer_booked = Session::get('customerID'); $validator = Validator::make(Input::all(), array('number_of_people' => 'required|integer', 'number_of_days' => 'required|integer', 'checkin' => 'required', 'checkout' => 'required', 'payment' => 'required')); if ($validator->fails()) { return Redirect::route('accommodation-details')->withErrors($validator)->withInput(); } else { $authenticatedUserCompId = Auth::user()->comp_id; $branchcode = $branch_id; $customerID = $customer_booked; $roomcode = $roomBooked_id; $peoplecount = Input::get('number_of_people'); $days = Input::get('number_of_days'); $checkin = Input::get('checkin'); $checkout = Input::get('checkout'); $paymehod = Input::get('payment'); $payedamount = $price_for_room; $bookedrooms = 1; $mytime = Carbon\Carbon::now(); $insertToAccommodationTable = DB::table('accommodation')->insert(['branch_code' => $branchcode, 'customer_id' => $customerID, 'room_code' => $roomcode, 'no_people' => $peoplecount, 'no_days' => $days, 'no_booked_rooms' => $bookedrooms, 'checkin_time' => $checkin, 'checkout_time' => $checkout, 'paid_amount' => $payedamount, 'paidby' => $paymehod, 'comp_id' => $authenticatedUserCompId, 'created_at' => $mytime->toDateTimeString(), 'updated_at' => $mytime->toDateTimeString()]); $updateHotelRoomsTable = DB::table('hotel_rooms')->where('room_code', '=', $roomcode)->update(array('status' => 'booked')); DB::table('sales')->insert(['company_id' => Auth::user()->comp_id, 'room_code' => $roomcode, 'branch_code' => $branchcode, 'sale_value' => $payedamount]); } } if ($insertToAccommodationTable && $updateHotelRoomsTable) { Session::forget('roomData', 'customerID'); return Redirect::route('book-room-own-hotel'); } else { return Redirect::route('accommodation-details'); } } else { $branchBooked = Session::get('roomData'); $room_id = $branchBooked['roomIDBook']; $branch_code = $branchBooked['branchBook']; $room_price = $branchBooked['priceBook']; $cutomerBooked = Session::get('customerID'); $validator = Validator::make(Input::all(), array('number_of_people' => 'required|integer', 'number_of_days' => 'required|integer', 'checkin' => 'required', 'checkout' => 'required', 'payment' => 'required')); if ($validator->fails()) { return Redirect::route('accommodation-details')->withErrors($validator)->withInput(); } else { $authenticatedUserCompId = Auth::user()->comp_id; $branchcode = $branch_code; $customerID = $cutomerBooked; $roomcode = $room_id; $peoplecount = Input::get('number_of_people'); $days = Input::get('number_of_days'); $checkin = Input::get('checkin'); $checkout = Input::get('checkout'); $paymehod = Input::get('payment'); $payedamount = $room_price; $bookedrooms = 1; $mytime = Carbon\Carbon::now(); $insertToAccommodationTable = DB::table('accommodation')->insert(['branch_code' => $branchcode, 'customer_id' => $customerID, 'room_code' => $roomcode, 'no_people' => $peoplecount, 'no_days' => $days, 'no_booked_rooms' => $bookedrooms, 'checkin_time' => $checkin, 'checkout_time' => $checkout, 'paid_amount' => $payedamount, 'paidby' => $paymehod, 'comp_id' => $authenticatedUserCompId, 'created_at' => $mytime->toDateTimeString(), 'updated_at' => $mytime->toDateTimeString()]); $updateHotelRoomsTable = DB::table('hotel_rooms')->where('room_code', '=', $roomcode)->update(array('status' => 'booked')); DB::table('sales')->insert(['company_id' => Auth::user()->comp_id, 'room_code' => $roomcode, 'branch_code' => $branchcode, 'sale_value' => $payedamount]); if ($insertToAccommodationTable && $updateHotelRoomsTable) { Session::forget('roomData', 'customerID'); return Redirect::route('book-room-own-hotel'); } else { return Redirect::route('accommodation-details'); } } } }
public function postSearch($item = "") { if (Request::ajax()) { if (isset($_POST['buypid'])) { $optionprice = $name = DB::table('products_options')->where('product_id', $_POST['buypid'])->where("option_value", $_POST['buyoption'])->pluck('price'); return $optionprice; exit; } if (isset($_POST['pid'])) { $item = Product::find($_POST['pid']); Cart::add(array('id' => $item->id, 'name' => $item->title, 'qty' => 1, 'price' => $item->price, 'options' => array('size' => Input::get("size"), 'buying' => Input::get('buying'), 'volume' => Input::get("volume"), 'optionid' => Input::get("optid"), 'weight' => Input::get("weight")))); $content = Cart::content(); Session::put("cartItems", $content); $total = Cart::total(); $itemHtml = ""; $itemHtml .= "<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (" . Cart::count() . ")</span> <i class='fa fa-chevron-down'></i></div>\n <div class='beta-dropdown cart-body'>"; if ($content) { foreach ($content as $itemRow) { $product = Product::find($itemRow->id); if ($itemRow->options->has('buying') && $itemRow->options->buying != "") { $itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price'); } if (public_path()) { $source_folder = public_path() . '/uploads/images/'; $destination_folder = public_path() . '/uploads/images/'; } else { $source_folder = '/home/medicalng/public_html/uploads/images/'; $destination_folder = '/home/medicalng/public_html/uploads/images/'; } $image_info = pathinfo($source_folder . $product->image); $image_extension = strtolower($image_info["extension"]); //image extension $image_name_only = strtolower($image_info["filename"]); //file name only, no extension $imgName = $image_name_only . "-50x50" . "." . $image_extension; $itemHtml .= "<div class='cart-item'>\n <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n <div class='media'>\n <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n <div class='media-body'>\n <span class='cart-item-title'>" . $itemRow->name . "</span>\n "; $itemHtml .= "<span class='cart-item-options'>"; $itemHtml .= $itemRow->options->has('size') ? " - Size: " . $itemRow->options->size : ''; $itemHtml .= $itemRow->options->has('buying') ? " - Buying Option: " . $itemRow->options->buying : ''; $itemHtml .= $itemRow->options->has('volume') ? " - Volume: " . $itemRow->options->volume : ''; $itemHtml .= "</span>"; $itemHtml .= "\n <span class='cart-item-amount'>{$itemRow->qty}*<span>₦" . number_format($itemRow->price, 2, '.', ',') . "</span>\n </div>\n </div>\n </div>\n\n "; } $itemHtml .= "<div class='cart-caption'>\n <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>₦" . number_format($total, 2, ".", ",") . "</span></div>\n <div class='clearfix'></div>\n\n <div class='center'>\n <div class='space10'> </div>\n <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n </div>\n </div>"; } else { $itemHtml .= "Cart is empty"; } $itemHtml .= "</div>"; echo $itemHtml; } if (isset($_POST['delid'])) { //$item = Product::find($_POST['delid']); Cart::remove($_POST['delid']); //(array('id' => $item->id, 'name' => $item->title, 'qty' => 1, 'price' => $item->price)); $content = Cart::content(); Session::put("cartItems", $content); $total = Cart::total(); $itemHtml = ""; $itemHtml .= "<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (" . Cart::count() . ")</span> <i class='fa fa-chevron-down'></i></div>\n <div class='beta-dropdown cart-body'>"; if ($content) { foreach ($content as $itemRow) { $product = Product::find($itemRow->id); if ($itemRow->options->has('buying') && $itemRow->options->buying != "") { $itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price'); } $image_info = pathinfo($source_folder . $product->image); $image_extension = strtolower($image_info["extension"]); //image extension $image_name_only = strtolower($image_info["filename"]); //file name only, no extension $imgName = $image_name_only . "-50x50" . "." . $image_extension; $itemHtml .= "<div class='cart-item'>\n <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n <div class='media'>\n <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n <div class='media-body'>\n <span class='cart-item-title'>" . $itemRow->name . "</span>\n "; $itemHtml .= "<span class='cart-item-options'>"; $itemHtml .= $itemRow->options->has('size') ? " - Size: " . $itemRow->options->size : ''; $itemHtml .= $itemRow->options->has('buying') ? " - Buying Option: " . $itemRow->options->buying : ''; $itemHtml .= $itemRow->options->has('volume') ? " - Volume: " . $itemRow->options->volume : ''; $itemHtml .= "</span>"; $itemHtml .= "\n <span class='cart-item-amount'>{$itemRow->qty}*<span>₦" . number_format($itemRow->price, 2, '.', ',') . "</span>\n </div>\n </div>\n </div>\n\n "; } $itemHtml .= "<div class='cart-caption'>\n <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>₦" . number_format($total, 2, ".", ",") . "</span></div>\n <div class='clearfix'></div>\n\n <div class='center'>\n <div class='space10'> </div>\n <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n </div></div>"; } else { $itemHtml .= "Cart is empty"; } $itemHtml .= "</div>"; echo $itemHtml; } } }
public function resetCartPrices() { $cart = \Cart::content(); foreach ($cart as $item) { $product = $this->product->find($item->id); if ($product) { \Cart::update($item->rowid, array('price' => $product->price_cents)); } } }
public function testCartCanDestroy() { Cart::add(1, 'test', 1, 10.0, array('size' => 'L')); Cart::destroy(); $this->assertEquals(Cart::count(), 0); $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartCollection', Cart::content()); }