Fix: Variant selection now requires choosing from ALL variant types

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 <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-10-06 02:11:06 +01:00
parent 330116e315
commit cb80e0161c

View File

@ -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)
{