/** * Test cart preview total product count when the same product is used multiple times */ public function testCartPreviewCount_DuplicateProducts() { $cart_srl = 774; $cart = new Cart($cart_srl); // Make sure we start with 4 products $this->assertEquals(4, count($cart->getProducts())); // Add one new product to cart (of the same type as one that already is in the cart) $product_repository = new ProductRepository(); $product = $product_repository->getProduct(133); $cart->addProduct($product, 1); // Make sure new product was added to cart $cart = new Cart($cart_srl); $this->assertEquals(5, $cart->count(TRUE)); $cart_preview = new CartPreview($cart, 2); $cart_preview_products = $cart_preview->getProducts(); $this->assertEquals(2, count($cart_preview_products)); $cart_products_count = $cart_preview->getCartProductsCount(); $this->assertEquals(5, $cart_products_count); }
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'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $carts = Cart::content(); if (Cart::count() < 1) { Session::flash('flash_error', 'You need add at least one product!'); } $order = new Order(); $order->user_id = Auth::user()->id; $order->date = date('Y-m-d h:i:s'); $order->total = money_format('%.2n', Cart::total()); $order->save(); foreach ($carts as $row) { $product = Product::find($row->id)->firstOrFail(); $orderDetail = new OrderDetail(); $orderDetail->order_id = $order->id; $orderDetail->product_id = $product->code; $orderDetail->quantity = $row->qty; $orderDetail->sub_total = money_format('%.2n', $row->subtotal); $orderDetail->save(); Cart::destroy(); } Session::flash('message', 'Successfully created order!'); return Redirect::to('orders'); }
Route::get('/color/{codigo}/imagen/{tamanio}', 'HiladosController@imagen'); Route::get('/accesorios', 'HiladosController@accesorios'); Route::get('/trajes-de-banio', 'MallasController@catalogo'); //}); //cierra el comment de compra con usuarios invitados //habiltar esto para compra con usuarios //Route::group(['middleware' => 'auth'], function () { //carrito Route::get('carrito/add', 'CarritoController@add'); Route::get('carrito/add/all/{codigo}', 'CarritoController@addAll'); Route::get('carrito/remove/{id}', 'CarritoController@remove'); Route::get('carrito/update/{rowId}/{cant}', 'CarritoController@update'); Route::get('carrito/header-cart', 'CarritoController@HeaderCart'); //pedido Route::get('revisar-pedido', function () { $viewname = \Cart::count() == 0 ? 'revisar-pedido-vacio' : 'revisar-pedido'; return view($viewname); }); Route::post('confirmar-pedido', 'CarritoController@ConfirmarPedido'); //}); //cierra el comment de compra con usuarios Route::get('/acerca-de-nube', function () { return view('acerca-de-nube'); }); Route::get('/locales', function () { return view('locales'); }); Route::get('/representantes', function () { return view('representantes'); }); Route::post('/lista-email', function () {
<span>Social Discount:</span> </td> <td class="text-right"> <span><?php echo '- $' . number_format($social_discount, 2); ?> </span> </td> </tr> <?php } ?> <?php if ($share_discount == 0) { if (Session::has('coupon_discount') && Cart::count() > 0) { ?> <tr> <td colspan="5"></td> <td class="text-left" colspan="2"> <span>Discount(coupon code {!! Session::get('coupon_code') !!}):</span> </td> <td class="text-right"> <span><?php echo '- $' . number_format($coupon_amount, 2); ?> </span> </td> </tr> <?php }
<tbody> <tr> <td>Sub Total:</td> <td> {!! $all_total !!}</td> </tr> <tr> <td>Total:</td> <td> {!! $all_total !!}</td> </tr> </tbody> </table> </div> </div> <?php if (Cart::count() > 0) { ?> <a class="butt full-disp" href="<?php echo url(); ?> /checkout-step1">Proceed to Checkout</a> <?php } ?> </div> </div> </div> </div> </div> </div> </div>
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'); } } } }
?> </div> </div> <div class="col-lg-6"> </div> <div class="col-lg-3"> <div class="well"> <div><?php echo link_to('cart', 'Ваша корзина'); ?> </div> <div><?php echo Cart::count(); ?> товара на <?php echo Cart::total(); ?> р.</div> </div> </div> </div> <div class="navbar navbar-default"> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="#" data-toggle="dropdown">Все категории <span class="caret"></span></a> <?php echo Cache::get('root_categories', function () {
public function testAddProduct() { $cart = new Cart(774); $pRepo = new ProductRepository(); $product1 = $pRepo->getProduct(130); $product2 = $pRepo->getProduct(133); $cart->emptyCart(); $this->assertEquals(0, $cart->count(), "Delete didn't work"); $cart->addProduct($product1); $this->assertEquals(1, $cart->count(), "Adding product 1 failed"); $this->assertEquals($cart->count(), count($cart->getProducts()), "?"); $cart->addProduct($product2, 1405); $this->assertEquals(2, $cart->count(), "Adding product 2 failed"); //getProducts should ignore its internal cache, so we tell it to. $this->assertEquals($cart->count(), count($cart->getProducts(NULL, NULL, TRUE)), "?"); }
public function agregarProducto($producto_id, $continue, $sec_id) { if (Cart::count(false) < 6) { $info = array('producto_id' => $producto_id); //Aca se manda a la funcion borrarItem de la clase Item //y se queda con la respuesta para redirigir cual sea el caso $respuesta = Carrito::agregarProducto($info); if ($respuesta['error']) { $estado = 'error'; $error = true; $producto_carrito_subido = false; } else { $estado = 'ok'; $error = false; $producto_carrito_subido = true; } } else { $respuesta['mensaje'] = Lang::get('controllers.carrito.maximo_permitido', ['cant' => 6]); $estado = 'error'; $error = true; $producto_carrito_subido = false; } $producto = Producto::find($producto_id); switch ($continue) { case 'home': $anclaProd = '#Pr' . $producto->id; if ($error) { return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/')->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } break; case 'seccion': if ($sec_id != "") { $seccion = Seccion::find($sec_id); if ($seccion) { $menu = $seccion->menuSeccion()->lang()->url; $ancla = '#' . $producto->item()->seccionItem()->estado . $producto->item()->seccionItem()->id; $anclaProd = '#Pr' . $producto->id; if ($error) { return Redirect::to('/' . $menu)->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/' . $menu)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } //return Redirect::to('/' . $menu)->with('mensaje', $respuesta['mensaje'])->with('ancla', $ancla)->with($estado, $error)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido)->with('anclaProd', $anclaProd); } else { if ($error) { return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/')->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } //return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } } else { if ($error) { return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/')->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } //return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } break; case 'carrito': if ($error) { return Redirect::to('/carrito')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/carrito')->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } //return Redirect::to('/carrito')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); break; default: if ($error) { return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('anclaProd', $anclaProd); } else { return Redirect::to('/')->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); } //return Redirect::to('/')->with('mensaje', $respuesta['mensaje'])->with($estado, $error)->with('producto_carrito', $producto)->with('producto_carrito_subido', $producto_carrito_subido); break; } }
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; } } }
/register">Sign Up</a></li> <li class="login"><a href="<?php echo url(); ?> /memberLogin">Login</a></li> <?php } ?> <?php //echo $cartval = Cart::count(); $cartval = ''; if (Session::has('member_userid')) { $cartval = isset($cart_value) ? $cart_value : ''; } else { if (Cart::count() > 0) { $cartval = Cart::count(); // Show the session cart value For logout user. } } // Checking brand login or not // if (!Session::has('brand_userid')) { ?> <li class="cart"><a href="javascript:void(0)" onClick="redirectToCart()"><span id="cart_det" <?php if ($cartval == '') { ?> style="display:none;" <?php } ?> ><?php echo $cartval; ?>
public function addToCart($id) { $barang = Barang::find($id); $tipe = Auth::user()->tipe; $qty = $_GET['qty']; if ($tipe == 1 || $tipe == 2) { $harga = $barang->harga_agenresmi; } elseif ($tipe == 3) { $harga = $barang->harga_agenlepas; } else { $harga = $barang->harga; } $data = ['id' => $barang->id, 'name' => $barang->nama, 'qty' => $qty, 'price' => $harga, 'options' => ['image' => $barang->gambar, 'berat' => $barang->berat]]; if (isset($_GET['aroma'])) { $data['options']['aroma'] = $_GET['aroma']; if (isset($_GET['aromaKedua'])) { $data['options']['aroma'] = $_GET['aromaKedua']; } } // dd($data['options']['aroma']); Cart::associate('Barang')->add($data); $cartContent = Cart::content(); // return View::make('store.cart', compact('cartContent')); return Cart::count(false); }
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 prepareCheckout() { $message = ''; $cart_total = Cart::total(); $cart_count = Cart::count(); // echo 'cart_count: '.$cart_count; // echo 'cart_total: '.$cart_total; if ($cart_total > 0 && $cart_count > 0) { //submit order $obj_order = $this->createOrder(); if ($obj_order) { //Attempt charge to Stripe gateway $token = Input::get('stripeToken'); $stripeEmail = Input::get('stripeEmail'); if (Auth::user()->check()) { $stripeEmail = Auth::user()->get()->email; } $description = Input::get('description'); $charge = false; try { Stripe::setApiKey(Config::get('services.stripe.secret_key')); $customer = Stripe_Customer::create(array('email' => $stripeEmail, 'card' => $token)); if ($customer) { $sum_amount = $obj_order->sum_amount; $charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $sum_amount * 100, 'currency' => 'usd', 'description' => $description)); } } catch (Stripe_CardError $e) { $messageTitle = 'Card Declined'; // Since it's a decline, Stripe_CardError will be caught $body = $e->getJsonBody(); $err = $body['error']; $message = $err['message']; } catch (Stripe_InvalidRequestError $e) { // Invalid parameters were supplied to Stripe's API $messageTitle = 'Oops...'; //$message = 'It looks like my payment processor encountered an error with the payment information. Please contact me before re-trying.'; $body = $e->getJsonBody(); $err = $body['error']; $message = $err['message']; } catch (Stripe_AuthenticationError $e) { // Authentication with Stripe's API failed // (maybe you changed API keys recently) $messageTitle = 'Oops...'; //$message = 'It looks like my payment processor API encountered an error. Please contact me before re-trying.'; $body = $e->getJsonBody(); $err = $body['error']; $message = $err['message']; } catch (Stripe_ApiConnectionError $e) { // Network communication with Stripe failed $messageTitle = 'Oops...'; //$message = 'It looks like my payment processor encountered a network error. Please contact me before re-trying.'; $body = $e->getJsonBody(); $err = $body['error']; $message = $err['message']; } catch (Stripe_Error $e) { // Display a very generic error to the user, and maybe send // yourself an email $messageTitle = 'Oops...'; //$message = 'It looks like my payment processor encountered an error. Please contact me before re-trying.'; $body = $e->getJsonBody(); $err = $body['error']; $message = $err['message']; } catch (Exception $e) { // Something else happened, completely unrelated to Stripe $messageTitle = 'Oops...'; //$message = 'It appears that something went wrong with your payment. Please contact me before re-trying.'; $message = $e->getMessage(); } if ($charge) { $obj_order->status = 'Charged'; $obj_order->save(); $message = 'Charged successfully!'; Session::flash('payment_message', $message); if (Auth::user()->check()) { return Redirect::route('home'); } else { return Redirect::route('payment'); } } } else { $message = 'It appears that something went wrong with your order. Please try again.'; } } else { $message = 'Your cart is empty, please shopping!'; } Session::flash('payment_message', $message); return Redirect::route('payment'); }
public function testCartCanHaveMultipleInstances() { Cart::instance('test_1')->add(1, 'test_1', 1, 10.0, array('size' => 'L')); Cart::instance('test_2')->add(2, 'test_2', 2, 10.0, array('size' => 'L')); $name = Cart::instance('test_1')->content()->first()->name; $this->assertEquals($name, 'test_1'); $name = Cart::instance('test_2')->content()->first()->name; $this->assertEquals($name, 'test_2'); $count = Cart::count(); $this->assertEquals($count, 2); Cart::add(3, 'test_3', 3, 10.0); $count = Cart::count(); $this->assertEquals($count, 5); Cart::instance('test_1')->add(1, 'test_1', 1, 10.0, array('size' => 'L')); $count = Cart::count(); $this->assertEquals($count, 2); }