This commit is contained in:
@@ -14,6 +14,9 @@ public sealed class CartService(LocalStorageService localStorage)
|
||||
|
||||
public event Action? OnCartChanged;
|
||||
|
||||
public static Func<Cart, long, int> GetCartItemQuantity = (shoppingCart, productPriceId) =>
|
||||
shoppingCart.Items.FirstOrDefault(p => p.Price!.Id == productPriceId)?.Quantity ?? 1;
|
||||
|
||||
public Cart GetCart() => ShoppingCart;
|
||||
|
||||
public void NotifyStateChanged() => OnCartChanged?.Invoke();
|
||||
@@ -123,7 +126,7 @@ public sealed class CartService(LocalStorageService localStorage)
|
||||
{
|
||||
if(ShoppingCart.CustomerId is not null || ShoppingCart.OrderId is not null)
|
||||
{
|
||||
ShoppingCart.TotalPrice = 0;
|
||||
ShoppingCart.TotalAmount = 0;
|
||||
ShoppingCart.TotalVat = 0;
|
||||
ShoppingCart.Items.Clear();
|
||||
|
||||
@@ -143,8 +146,8 @@ public sealed class CartService(LocalStorageService localStorage)
|
||||
|
||||
if (!ShoppingCart.IsVatInclusive) ShoppingCart.TotalVat = gross * ShoppingCart.VatRate;
|
||||
|
||||
ShoppingCart.TotalPrice = gross + ShoppingCart.TotalVat;
|
||||
ShoppingCart.TotalAmount = gross + ShoppingCart.TotalVat;
|
||||
|
||||
return ShoppingCart.TotalPrice;
|
||||
return ShoppingCart.TotalAmount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public sealed class Cart
|
||||
|
||||
public long? OrderId { get; set; }
|
||||
|
||||
public decimal TotalPrice { get; set; }
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
public decimal TotalVat { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user