From a999156c0887471ba0b6f389742b3abaff2e7c39 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Fri, 25 Sep 2026 12:05:09 +0200 Subject: [PATCH] fix(ws): cart.confirm reads the cart fresh before deciding it was converted Co-Authored-By: Claude Opus 5.5 (1M context) --- src/Websocket/Controllers/CartController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Websocket/Controllers/CartController.php b/src/Websocket/Controllers/CartController.php index 92544db..a99421f 100644 --- a/src/Websocket/Controllers/CartController.php +++ b/src/Websocket/Controllers/CartController.php @@ -200,10 +200,11 @@ class CartController extends \BlaxSoftware\LaravelWebSockets\Websocket\Controlle $order = $result['order']; // booted() adopted the client's cart before the payment was settled; a - // converted cart hands this connection a fresh one. - if ($this->cart->isConverted()) { - $this->cart = CartFacade::adopt(null, $this->connection->socketId); - } + // cart that became an order since hands this connection a fresh one. + $current = $this->cart->fresh(); + $this->cart = ($current && ! $current->isConverted()) + ? $current + : CartFacade::adopt(null, $this->connection->socketId); return $this->success([ 'status' => $result['status'], @@ -212,7 +213,7 @@ class CartController extends \BlaxSoftware\LaravelWebSockets\Websocket\Controlle 'order_number' => $order->order_number, 'status' => $order->status, ] : null, - 'cart' => CartResource::make($this->cart->fresh()), + 'cart' => CartResource::make($this->cart), ]); }