From 16ec41cccaf6475f603dd7b9b24ecdcebeb4995f Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Fri, 3 Oct 2025 17:08:11 +0100 Subject: [PATCH] Fix: Replace Quick Buy/Details buttons with single Buy button using short IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ProductCarouselService: Use Buy button with short IDs for products without images - CallbackHandler: Fix HandleCategory to use Buy button with short IDs - MenuBuilder: Remove obsolete SingleProductMenu method This ensures consistent behavior across all product displays and fixes the Details button that was broken due to GUID format incompatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- TeleBot/TeleBot/Handlers/CallbackHandler.cs | 14 +++++++++++++- .../TeleBot/Services/ProductCarouselService.cs | 15 +++++++++++++-- TeleBot/TeleBot/UI/MenuBuilder.cs | 10 ---------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/TeleBot/TeleBot/Handlers/CallbackHandler.cs b/TeleBot/TeleBot/Handlers/CallbackHandler.cs index dffbac7..f9cbb83 100644 --- a/TeleBot/TeleBot/Handlers/CallbackHandler.cs +++ b/TeleBot/TeleBot/Handlers/CallbackHandler.cs @@ -298,11 +298,23 @@ namespace TeleBot.Handlers { foreach (var product in products.Items) { + // Create Buy button with short ID format + var buyButton = new InlineKeyboardMarkup(new[] + { + new[] + { + InlineKeyboardButton.WithCallbackData( + $"🛒 Buy {product.Name}", + _mapper.BuildCallback("product", product.Id) + ) + } + }); + await bot.SendTextMessageAsync( message.Chat.Id, MessageFormatter.FormatSingleProduct(product), parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, - replyMarkup: MenuBuilder.SingleProductMenu(product.Id) + replyMarkup: buyButton ); } diff --git a/TeleBot/TeleBot/Services/ProductCarouselService.cs b/TeleBot/TeleBot/Services/ProductCarouselService.cs index cfb82f4..91362cd 100644 --- a/TeleBot/TeleBot/Services/ProductCarouselService.cs +++ b/TeleBot/TeleBot/Services/ProductCarouselService.cs @@ -91,12 +91,23 @@ namespace TeleBot.Services } else { - // If no image, send as text message instead + // If no image, send as text message with Buy button + var buyButton = new InlineKeyboardMarkup(new[] + { + new[] + { + InlineKeyboardButton.WithCallbackData( + $"🛒 Buy {product.Name}", + _mapper.BuildCallback("product", product.Id) + ) + } + }); + await botClient.SendTextMessageAsync( chatId, FormatProductCaption(product), parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, - replyMarkup: MenuBuilder.SingleProductMenu(product.Id) + replyMarkup: buyButton ); } diff --git a/TeleBot/TeleBot/UI/MenuBuilder.cs b/TeleBot/TeleBot/UI/MenuBuilder.cs index 9296b04..cc8c847 100644 --- a/TeleBot/TeleBot/UI/MenuBuilder.cs +++ b/TeleBot/TeleBot/UI/MenuBuilder.cs @@ -542,16 +542,6 @@ namespace TeleBot.UI }; } - public static InlineKeyboardMarkup SingleProductMenu(Guid productId) - { - return new InlineKeyboardMarkup(new[] - { - new[] { - InlineKeyboardButton.WithCallbackData("🛒 Quick Buy", $"quickbuy:{productId}:1"), - InlineKeyboardButton.WithCallbackData("📄 Details", $"product:{productId}") - } - }); - } public static InlineKeyboardMarkup ProductMultiBuysMenu(Product product, int defaultQuantity = 1) {