fix bugs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user