fix(ws): cart.confirm reads the cart fresh before deciding it was converted
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6aae653dac
commit
a999156c08
|
|
@ -200,10 +200,11 @@ class CartController extends \BlaxSoftware\LaravelWebSockets\Websocket\Controlle
|
||||||
$order = $result['order'];
|
$order = $result['order'];
|
||||||
|
|
||||||
// booted() adopted the client's cart before the payment was settled; a
|
// booted() adopted the client's cart before the payment was settled; a
|
||||||
// converted cart hands this connection a fresh one.
|
// cart that became an order since hands this connection a fresh one.
|
||||||
if ($this->cart->isConverted()) {
|
$current = $this->cart->fresh();
|
||||||
$this->cart = CartFacade::adopt(null, $this->connection->socketId);
|
$this->cart = ($current && ! $current->isConverted())
|
||||||
}
|
? $current
|
||||||
|
: CartFacade::adopt(null, $this->connection->socketId);
|
||||||
|
|
||||||
return $this->success([
|
return $this->success([
|
||||||
'status' => $result['status'],
|
'status' => $result['status'],
|
||||||
|
|
@ -212,7 +213,7 @@ class CartController extends \BlaxSoftware\LaravelWebSockets\Websocket\Controlle
|
||||||
'order_number' => $order->order_number,
|
'order_number' => $order->order_number,
|
||||||
'status' => $order->status,
|
'status' => $order->status,
|
||||||
] : null,
|
] : null,
|
||||||
'cart' => CartResource::make($this->cart->fresh()),
|
'cart' => CartResource::make($this->cart),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue