This commit is contained in:
2026-02-09 15:59:46 +03:30
parent 8c9e7053f5
commit b6d94964f9
4 changed files with 18 additions and 18 deletions
+8 -4
View File
@@ -89,7 +89,7 @@ export class CartService {
paymentMethodId,
);
// Recalculate totals first so wallet check uses up-to-date total (delivery method may have changed above).
// Recalculate totals first so wallet check uses up-to-date total (delivery method/address may have changed above).
await this.calculationService.recalculateCartTotals(cart);
if (paymentMethod.method === PaymentMethodEnum.Wallet) {
@@ -103,8 +103,8 @@ export class CartService {
cart.description = description;
}
// Final recalculation + save and return cart
return this.recalculateAndSaveCart(cart);
// Save and return cart (totals already recalculated above)
return this.saveTouchedCart(cart);
}
/**
@@ -290,7 +290,7 @@ export class CartService {
fullName: `${address.user.firstName || ''} ${address.user.lastName || ''}`.trim(),
phone: address.user.phone,
};
return this.saveTouchedCart(cart);
return this.recalculateAndSaveCart(cart);
}
/**
@@ -307,6 +307,10 @@ export class CartService {
shopId,
paymentMethodId,
);
// Recalculate totals first so wallet check uses up-to-date total
await this.calculationService.recalculateCartTotals(cart);
if (paymentMethod.method === PaymentMethodEnum.Wallet) {
await this.validationService.assertWalletHasEnoughBalance(userId, shopId, cart.total);
}