From cb80e0161cffdcea63ef4e9f3d1a3944343b4832 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Mon, 6 Oct 2025 02:11:06 +0100 Subject: [PATCH] Fix: Variant selection now requires choosing from ALL variant types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Product with Size + Color only required selecting 1 variant total - User could add to cart after selecting just Size OR Color, not both Root Cause: - Logic checked if selectedVariants.Count == 1 for single items - Didn't verify that all variant types were covered Fix: - For single items: Check that each variant type has at least one selection - Logic: variantGroups.All(g => g.Any(v => selectedVariants.Contains(v.Name))) - For multi-buy: Keep existing logic (total count == quantity) Now users must select: - Size + Color products: Must pick both Size AND Color - Size only products: Must pick Size only - Etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- TeleBot/TeleBot/UI/MenuBuilder.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/TeleBot/TeleBot/UI/MenuBuilder.cs b/TeleBot/TeleBot/UI/MenuBuilder.cs index 692bf2a..090f003 100644 --- a/TeleBot/TeleBot/UI/MenuBuilder.cs +++ b/TeleBot/TeleBot/UI/MenuBuilder.cs @@ -498,7 +498,19 @@ namespace TeleBot.UI } // Add confirm button when selections are complete - bool canConfirm = quantity == 1 ? selectedVariants.Count == 1 : selectedVariants.Count == quantity; + // For single items: need one selection from each variant type + // For multi-buy: need total selections == quantity + bool canConfirm; + if (quantity == 1) + { + // Check if all variant types have at least one selection + canConfirm = variantGroups.All(g => g.Any(v => selectedVariants.Contains(v.Name))); + } + else + { + // Multi-buy: need total selections == quantity + canConfirm = selectedVariants.Count == quantity; + } if (canConfirm) {