refactor(checkout): keep source cart active
This commit is contained in:
@@ -274,13 +274,6 @@ class StartCheckoutService
|
||||
);
|
||||
}
|
||||
|
||||
// The purchase owns the reservation until checkout finishes. The cart is
|
||||
// retained so it can be restored if the purchase is cancelled or expires.
|
||||
$cart->update([
|
||||
'status' => 'checkout',
|
||||
'guest_token' => null,
|
||||
]);
|
||||
|
||||
return $this->loadPurchase($purchase);
|
||||
}
|
||||
|
||||
@@ -299,6 +292,14 @@ class StartCheckoutService
|
||||
]);
|
||||
}
|
||||
|
||||
if ($cart->purchases()
|
||||
->whereIn('status', [Purchase::STATUS_CREATED, Purchase::STATUS_PENDING_PAYMENT])
|
||||
->exists()) {
|
||||
throw ValidationException::withMessages([
|
||||
'cart_id' => __('api.purchase.checkout_in_progress'),
|
||||
]);
|
||||
}
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user