From 5ab2c51aa8e82fb6b9b371b295a9fa248d4cfb32 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Mon, 6 Oct 2025 00:46:35 +0100 Subject: [PATCH] Enhancement: Show proper order details instead of GUIDs - OrderListMenu now shows item summary (e.g., '2x Product Name' or 'Product Name +2 more') - FormatCart enhanced to show variant selections and multi-buy indicators - FormatOrder enhanced to show variant names and detailed item breakdown - Cart now clearly distinguishes between multi-buy bundles and regular items - Order confirmations now show full product and variant details Replaced generic GUID displays with human-readable product information for better UX. --- TeleBot/TeleBot/UI/MenuBuilder.cs | 28 +++++++++++++--- TeleBot/TeleBot/UI/MessageFormatter.cs | 45 ++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/TeleBot/TeleBot/UI/MenuBuilder.cs b/TeleBot/TeleBot/UI/MenuBuilder.cs index e1588ef..692bf2a 100644 --- a/TeleBot/TeleBot/UI/MenuBuilder.cs +++ b/TeleBot/TeleBot/UI/MenuBuilder.cs @@ -329,20 +329,40 @@ namespace TeleBot.UI public static InlineKeyboardMarkup OrderListMenu(List orders) { var buttons = new List(); - + foreach (var order in orders.Take(10)) // Limit to 10 most recent { var status = GetOrderStatusEmoji(order.Status); + + // Build a summary of items in the order + var itemSummary = ""; + if (order.Items.Any()) + { + var firstItem = order.Items.First(); + if (order.Items.Count == 1) + { + itemSummary = $"{firstItem.Quantity}x {firstItem.ProductName}"; + } + else + { + itemSummary = $"{firstItem.ProductName} +{order.Items.Count - 1} more"; + } + } + else + { + itemSummary = "Empty order"; + } + buttons.Add(new[] { InlineKeyboardButton.WithCallbackData( - $"{status} Order {order.Id.ToString().Substring(0, 8)} - £{order.TotalAmount:F2}", + $"{status} {itemSummary} - £{order.TotalAmount:F2}", $"order:{order.Id}" ) }); } - + buttons.Add(new[] { InlineKeyboardButton.WithCallbackData("⬅️ Back to Menu", "menu") }); - + return new InlineKeyboardMarkup(buttons); } diff --git a/TeleBot/TeleBot/UI/MessageFormatter.cs b/TeleBot/TeleBot/UI/MessageFormatter.cs index a86a63c..6b510b0 100644 --- a/TeleBot/TeleBot/UI/MessageFormatter.cs +++ b/TeleBot/TeleBot/UI/MessageFormatter.cs @@ -192,24 +192,46 @@ namespace TeleBot.UI { var sb = new StringBuilder(); sb.AppendLine("🛒 *Shopping Cart*\n"); - + if (cart.IsEmpty()) { sb.AppendLine("Your cart is empty.\n"); sb.AppendLine("Browse products to add items to your cart."); return sb.ToString(); } - + foreach (var item in cart.Items) { - sb.AppendLine($"• *{item.ProductName}*"); - sb.AppendLine($" Qty: {item.Quantity} × £{item.UnitPrice:F2} = *£{item.TotalPrice:F2}*"); + // Build item display with variants/multi-buy info + var itemDisplay = item.ProductName; + + // Show variant if selected + if (item.SelectedVariants?.Any() == true) + { + itemDisplay += $" ({string.Join(", ", item.SelectedVariants)})"; + } + else if (!string.IsNullOrEmpty(item.SelectedVariant)) + { + itemDisplay += $" ({item.SelectedVariant})"; + } + + // Show if it's a multi-buy + if (item.MultiBuyId.HasValue) + { + sb.AppendLine($"• *{itemDisplay}* _(Multi-buy Bundle)_"); + sb.AppendLine($" Bundle Price: *£{item.UnitPrice:F2}*"); + } + else + { + sb.AppendLine($"• *{itemDisplay}*"); + sb.AppendLine($" Qty: {item.Quantity} × £{item.UnitPrice:F2} = *£{item.TotalPrice:F2}*"); + } } - + sb.AppendLine($"\n📊 *Summary:*"); sb.AppendLine($"Items: {cart.GetTotalItems()}"); sb.AppendLine($"*Total: £{cart.GetTotalAmount():F2}*"); - + return sb.ToString(); } @@ -276,7 +298,16 @@ namespace TeleBot.UI sb.AppendLine("\n*Items:*"); foreach (var item in order.Items) { - sb.AppendLine($"• {item.ProductName} - Qty: {item.Quantity} - £{item.TotalPrice:F2}"); + var itemDisplay = item.ProductName ?? "Unknown Product"; + + // Add variant info if available + if (!string.IsNullOrEmpty(item.ProductVariantName)) + { + itemDisplay += $" ({item.ProductVariantName})"; + } + + sb.AppendLine($"• {itemDisplay}"); + sb.AppendLine($" Qty: {item.Quantity} × £{item.UnitPrice:F2} = £{item.TotalPrice:F2}"); } }