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.
This commit is contained in:
SysAdmin 2025-10-06 00:46:35 +01:00
parent 6c79c04ebd
commit 5ab2c51aa8
2 changed files with 62 additions and 11 deletions

View File

@ -329,20 +329,40 @@ namespace TeleBot.UI
public static InlineKeyboardMarkup OrderListMenu(List<Order> orders) public static InlineKeyboardMarkup OrderListMenu(List<Order> orders)
{ {
var buttons = new List<InlineKeyboardButton[]>(); var buttons = new List<InlineKeyboardButton[]>();
foreach (var order in orders.Take(10)) // Limit to 10 most recent foreach (var order in orders.Take(10)) // Limit to 10 most recent
{ {
var status = GetOrderStatusEmoji(order.Status); 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[] { buttons.Add(new[] {
InlineKeyboardButton.WithCallbackData( InlineKeyboardButton.WithCallbackData(
$"{status} Order {order.Id.ToString().Substring(0, 8)} - £{order.TotalAmount:F2}", $"{status} {itemSummary} - £{order.TotalAmount:F2}",
$"order:{order.Id}" $"order:{order.Id}"
) )
}); });
} }
buttons.Add(new[] { InlineKeyboardButton.WithCallbackData("⬅️ Back to Menu", "menu") }); buttons.Add(new[] { InlineKeyboardButton.WithCallbackData("⬅️ Back to Menu", "menu") });
return new InlineKeyboardMarkup(buttons); return new InlineKeyboardMarkup(buttons);
} }

View File

@ -192,24 +192,46 @@ namespace TeleBot.UI
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine("🛒 *Shopping Cart*\n"); sb.AppendLine("🛒 *Shopping Cart*\n");
if (cart.IsEmpty()) if (cart.IsEmpty())
{ {
sb.AppendLine("Your cart is empty.\n"); sb.AppendLine("Your cart is empty.\n");
sb.AppendLine("Browse products to add items to your cart."); sb.AppendLine("Browse products to add items to your cart.");
return sb.ToString(); return sb.ToString();
} }
foreach (var item in cart.Items) foreach (var item in cart.Items)
{ {
sb.AppendLine($"• *{item.ProductName}*"); // Build item display with variants/multi-buy info
sb.AppendLine($" Qty: {item.Quantity} × £{item.UnitPrice:F2} = *£{item.TotalPrice:F2}*"); 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($"\n📊 *Summary:*");
sb.AppendLine($"Items: {cart.GetTotalItems()}"); sb.AppendLine($"Items: {cart.GetTotalItems()}");
sb.AppendLine($"*Total: £{cart.GetTotalAmount():F2}*"); sb.AppendLine($"*Total: £{cart.GetTotalAmount():F2}*");
return sb.ToString(); return sb.ToString();
} }
@ -276,7 +298,16 @@ namespace TeleBot.UI
sb.AppendLine("\n*Items:*"); sb.AppendLine("\n*Items:*");
foreach (var item in order.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}");
} }
} }