/// <summary> /// Gets total cost of shopping cart, returns currency formatted string /// </summary> /// <returns></returns> public string GetCartTotal() { decimal?totalPrice = 0; var carts = db.ShoppingCarts.Include("Product").Where(x => x.CartID == ShoppingCartID); foreach (var item in carts) { if (item.Product.WildmanPrice != null) { totalPrice += item.Product.WildmanPrice * item.Quantity; } else { totalPrice += item.Product.Price * item.Quantity; } } return(StringFormatting.FormattedPrice(totalPrice ?? 0)); }