feat(checkout): route carts to replacement variants
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Domains\Purchase\Services\Checkout;
|
||||
|
||||
use App\Domains\Cart\Models\Cart;
|
||||
use App\Domains\Cart\Models\CartItem;
|
||||
use App\Domains\Cart\Services\CartVariantReplacementService;
|
||||
use App\Domains\Catalog\Exceptions\StockReservationExpiredException;
|
||||
use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Catalog\Models\Variant;
|
||||
@@ -29,6 +30,7 @@ class StartCheckoutService
|
||||
private readonly InsufficientStockMessageBuilder $stockMessages,
|
||||
private readonly PurchaseResponseLoader $responses,
|
||||
private readonly PurchaseItemSnapshotFactory $snapshots,
|
||||
private readonly CartVariantReplacementService $variantReplacements,
|
||||
) {}
|
||||
|
||||
/** @param array<string, mixed> $purchaseData */
|
||||
@@ -250,6 +252,7 @@ class StartCheckoutService
|
||||
int $cartId,
|
||||
): Purchase {
|
||||
$cart = $this->resolveCart($tenant, $userId, $cartId);
|
||||
$this->variantReplacements->replaceHistoricalVariants($cart);
|
||||
$cartItems = $cart->items()->lockForUpdate()->get();
|
||||
|
||||
if ($cartItems->isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user