Fix: Replace Quick Buy/Details buttons with single Buy button using short IDs

- 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 <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-10-03 17:08:11 +01:00
parent 3a8d576b64
commit 16ec41ccca
3 changed files with 26 additions and 13 deletions

View File

@ -298,11 +298,23 @@ namespace TeleBot.Handlers
{ {
foreach (var product in products.Items) 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( await bot.SendTextMessageAsync(
message.Chat.Id, message.Chat.Id,
MessageFormatter.FormatSingleProduct(product), MessageFormatter.FormatSingleProduct(product),
parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown,
replyMarkup: MenuBuilder.SingleProductMenu(product.Id) replyMarkup: buyButton
); );
} }

View File

@ -91,12 +91,23 @@ namespace TeleBot.Services
} }
else 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( await botClient.SendTextMessageAsync(
chatId, chatId,
FormatProductCaption(product), FormatProductCaption(product),
parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown,
replyMarkup: MenuBuilder.SingleProductMenu(product.Id) replyMarkup: buyButton
); );
} }

View File

@ -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) public static InlineKeyboardMarkup ProductMultiBuysMenu(Product product, int defaultQuantity = 1)
{ {