-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CheckoutSuccessPage retrieves wrong cart #92
Comments
Continuing to investigate this for my own learning and to help out... I've been stepping through the code to determine where the session changes and I think I've found it. In my debug console I was running To illustrate using excerpt from public function authorize(): ?PaymentAuthorize
{
if (! $this->order) {
if (! $this->order = $this->cart->draftOrder()->first()) {
$this->order = $this->cart->createOrder();
}
}
$orderMeta = array_merge(
(array) $this->order->meta,
$this->data['meta'] ?? []
);
$status = $this->data['authorized'] ?? null;
//
// (after executing line above) Lunar\Facades\CartSession::current()->id = N
//
$this->order->update([
'status' => $status ?? ($this->config['authorized'] ?? null),
'meta' => $orderMeta,
'placed_at' => now(),
]);
//
// (after executing line above) Lunar\Facades\CartSession::current()->id = N + 1
// The CartSession ID increments by 1 after updating the order
//
$response = new PaymentAuthorize(
success: true,
orderId: $this->order->id,
paymentType: 'offline',
);
PaymentAttemptEvent::dispatch($response);
return $response;
} Not sure yet why this is occurring - but wanted to capture my findings. Perhaps this is a bug with Lunar core? |
I think the issue here is the Starter kit is quite outdated at this point, we're working on new starter kits for v1 and to bring this back up to speed with the latest beta. There was a change to the way carts are retrieved from the session after a cart completed an order, so because you're trying to fetch the cart afterwards, it has a completed order and therefore returns a new cart. So, in the case of the offline payment, you would need to pass the cart id to the success page to fetch it that way instead of going through the session manager. |
You can see this on this PR which is awaiting review by @glennjacobs #89 |
If I may add my opinion, the Livewire Starter kit works really well except for a few minor issues. |
I noticed that when submitting an order, there is no confirmation and it redirects to the main storefront (
/
).After some debugging and tracing, I believe I've tracked down what's happening but I'm not sure why.
CheckoutPage->checkout()
redirects on successful offline payment.CheckoutSuccessPage->mount()
runs, theCartSession::current()
retrieves an apparently new session with an ID=N+1. For example, when the payment succeeds the cart ID might be 8, but inCheckoutSuccessPage
the ID will be 9.completedOrder
to fail, and redirect to the main storefront without displaying thecheckout-success.view
The text was updated successfully, but these errors were encountered: