Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

War3_brent2's avatar

How to update product value after checkout in Laravel Session

Good Day I need your help. How can I decrement a quantity of a specific item in the table after I do the checkout?. Cant really think of a way how to do it. Thank you for the reply

public function postCheckout(Request $request){

    if (!Session::has('cart')){
         return view('shop.shoppingcart');

    }
    $oldCart = Session::get('cart');
    $cart = new Cart($oldCart);
    $order = new Order();
    $order->cart = serialize($cart);
    $order->address = $request->input('address');
    $order->name = $request->input('name');
  

 Auth::user()->orders()->save($order);
    
   Session::forget('cart');

   return redirect("home");
}
0 likes
1 reply

Please or to participate in this conversation.