@page "/cart"

Your Cart

CONTINUE SHOPPING
@if (!CartItems.Any()) {

Your collection is currently empty.

Browse Catalog
} else {
@foreach (var item in CartItems) {
[COVER]
@item.Title

by @item.Author

@item.Quantity
R @(item.Price * item.Quantity)
}
Subtotal R @Subtotal.ToString("F2")
VAT (15%) R @VatAmount.ToString("F2")

Total R @Total.ToString("F2")
Proceed to Checkout
}
@code { public class CartItem { public int Id { get; set; } public string Title { get; set; } = string.Empty; public string Author { get; set; } = string.Empty; public int Price { get; set; } public int Quantity { get; set; } } private List CartItems = new() { new CartItem { Id = 1, Title = "Letters from M/M (Paris)", Author = "M/M Paris", Price = 720, Quantity = 1 }, new CartItem { Id = 2, Title = "Daan Paans: Floating Signifiers", Author = "Daan Paans", Price = 540, Quantity = 1 }, new CartItem { Id = 3, Title = "Album Architectures, Maputo", Author = "Guedes Archive", Price = 350, Quantity = 1 } }; // Computed Properties for Calculations private decimal Subtotal => CartItems.Sum(i => (decimal)i.Price * i.Quantity); private decimal VatAmount => Subtotal * 0.15m; private decimal Total => Subtotal + VatAmount; private void ChangeQuantity(CartItem item, int delta) { item.Quantity += delta; if (item.Quantity <= 0) CartItems.Remove(item); } private void RemoveFromCart(CartItem item) => CartItems.Remove(item); }