@page "/checkout" @inject NavigationManager Navigation

Checkout

Your Items
@foreach (var item in CartItems) {
@item.Title
@item.Author
@item.Quantity
}
Shipping Method
Shipping Address
Order Summary
SubtotalR @Subtotal.ToString("F2")
VAT (15%)R @VatAmount.ToString("F2")
ShippingR @ShippingCost.ToString("F2")

Total Due

R @((Subtotal + VatAmount + ShippingCost).ToString("F2"))

@code { private decimal ShippingCost = 0; private bool IsSameAddress = true; // Calculations private decimal Subtotal => CartItems.Sum(i => (decimal)i.Price * i.Quantity); private decimal VatAmount => Subtotal * 0.15m; // Assuming your CartItems list is managed via a Service or cascading parameter // Here it is locally mocked for this example 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 } }; 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); private int GetCartTotal() => CartItems.Sum(i => i.Price * i.Quantity); public class CartItem { public int Id { get; set; } public string Title { get; set; } = ""; public string Author { get; set; } = ""; public int Price { get; set; } public int Quantity { get; set; } } private void CompletePurchase(MouseEventArgs args) { Navigation.NavigateTo("/payment-confirmation"); } }