public function postCheckout(Request $request) { \DB::beginTransaction(); $customer = Customer::create($request->all()); $order = $customer->orders()->create(['quantity' => \Cart::getTotalQuantity(), 'total' => \Cart::getTotal(), 'shipped' => false]); foreach (\Cart::getContent() as $cart) { $order->details()->create(['deal_id' => $cart->id, 'quantity' => $cart->quantity, 'price' => $cart->price]); } $order->push(); $customer->push(); \DB::commit(); \Cart::clear(); return view('frontend.checkout.done')->with('categories', Category::all()); }
ID 名称 价格 数量 <br> <?php $rs = Cart::getContent(); foreach ($rs as $item) { ?> {{ $item->id }} {{ $item->name }} {{ $item->price }} {{ $item->quantity }} {{ $item->attributes }} <br> <?php } ?> <a href="{{ url('cart/checkout') }}">确认购买</a>
if (Request::ajax()) { $product_id = Request::get('id'); //Cart::remove($product_id); //Cart::clear(); $cartData = Cart::getContent(); return $cartData->toArray(); } else { return "not ajax"; } }); Route::post('/product/deletecart', function () { if (Request::ajax()) { $product_id = Request::get('id'); Cart::remove($product_id); //Cart::clear(); $cartData = Cart::getContent(); return $cartData->toJson(); } else { return "not ajax"; } }); Route::post('product/add_to_cart', function () { if (Request::ajax()) { $i = 0; $data = Input::all(); //return $data[]; //dd($fonts); foreach ($data['dataArr'] as $val) { echo $val['color']; } //$ar = explode(':', $datam[0]);
@extends('layout.main') @section('content') @if(Cart::getTotalQuantity() == 0) <div class="register_account"> <div class="wrap"> <h4 class="title">Shopping cart is empty</h4> <p class="cart">You have no items in your shopping cart.<br>Click<a href="/home"> here</a> to continue shopping</p> </div> </div> @else <?php $items = Cart::getContent(); ?> <div class = "container-fluid"> @foreach($items as $item) <?php $item = App\products::find($item->id); ?> <div class = "col-md-4" style = "max-height:172px;margin-bottom:100px;"> <div class="inner_content clearfix"> <div class="product_image"> <img style = "max-height:152px" src="{{App\configStrategy::getGomecoInventoryWebsite()}}{{$item->picture}}" alt=""/> </div> <div class="price"> <div class="cart-left"> <p class="title">{{$item->productName}}</p> <div class="price1"> <span class="actual">₱ {{$item->sellingprice}}</span> </div> <a href="product/{{$item->id}}">view details</a>