Choice Sets
Overview
Choice sets define groups of products that customers can choose from when building a bundle. Each bundle can have multiple choice sets.
Choice Set Structure
interface BundleSet {
id: string;
bundleId: string;
title: string;
description?: string;
minQuantity: number; // Required picks (0-15)
maxQuantity: number; // Allowed picks (1-15)
sortOrder: number; // Display order
items: BundleSetItem[];
createdAt: Date;
updatedAt: Date;
}
Quantity Constraints
Min Quantity
- Minimum: 0 (optional set)
- Maximum: 15
- Purpose: Number of items customer must select
Max Quantity
- Minimum: 1
- Maximum: 15
- Purpose: Maximum items customer can select
- Constraint:
maxQuantity >= minQuantity
Set Types
Required Set
When minQuantity > 0:
- Customer must select at least
minQuantityitems - Example: "Choose at least 1 T-shirt"
Optional Set
When minQuantity = 0:
- Customer can skip this set
- Example: "Add a gift (optional)"
Single Choice Set
When minQuantity = maxQuantity = 1:
- Customer must select exactly 1 item
- Also called "Option Set"
- Example: "Choose your size"
Multiple Choice Set
When maxQuantity > 1:
- Customer can select multiple items
- Example: "Choose up to 3 accessories"
Creating a Choice Set
POST /admin/bundles/:bundleId/sets
Content-Type: application/json
{
"title": "Choose your T-shirt",
"description": "Select one T-shirt from the options",
"minQuantity": 1,
"maxQuantity": 1
}
Adding Items to a Set
POST /admin/bundles/:bundleId/sets/:setId/items
Content-Type: application/json
{
"variantId": "tshirt-red-m"
}
Selection Validation
When customer selects items, validation checks:
- Set Presence: All sets with
minQuantity > 0must have selections - Quantity Range: Selections must be between min and max
- Item Validity: Selected items must exist in the set
- No Duplicates: Same item can't be selected twice (unless
allowMixAndMatch: true)
Example: T-Shirt Bundle
{
"bundle": {
"title": "Custom T-Shirt Bundle",
"sets": [
{
"title": "Choose your T-shirt",
"minQuantity": 1,
"maxQuantity": 1,
"items": [
{ "variantId": "tshirt-red-m" },
{ "variantId": "tshirt-blue-m" },
{ "variantId": "tshirt-green-m" }
]
},
{
"title": "Add accessories (optional)",
"minQuantity": 0,
"maxQuantity": 3,
"items": [
{ "variantId": "cap-black" },
{ "variantId": "socks-white" },
{ "variantId": "bag-red" }
]
}
]
}
}
Valid Selections:
- T-shirt: 1 item (required)
- Accessories: 0-3 items (optional)
Invalid Selections:
- T-shirt: 0 items ❌ (minQuantity = 1)
- Accessories: 4 items ❌ (maxQuantity = 3)
Sort Order
Sets are displayed in sortOrder order:
- Lower numbers appear first
- Default: Sets created later have higher sortOrder
- Can be updated to reorder sets
API Endpoints
POST /admin/bundles/:bundleId/sets- Create choice setGET /admin/bundles/:bundleId/sets- List sets for bundleGET /admin/bundles/:bundleId/sets/:setId- Get setPATCH /admin/bundles/:bundleId/sets/:setId- Update setDELETE /admin/bundles/:bundleId/sets/:setId- Delete setPOST /admin/bundles/:bundleId/sets/:setId/items- Add item to setDELETE /admin/bundles/:bundleId/sets/:setId/items/:itemId- Remove item from set
Limits
- Max Sets per Bundle: 15
- Max Items per Set: No hard limit (but keep reasonable)
- Min/Max Quantity: 0-15
Best Practices
- Clear Titles: Use descriptive titles for each set
- Reasonable Limits: Keep quantities reasonable (1-5 for most cases)
- Logical Ordering: Order sets logically (required first, optional last)
- Test Validation: Test all quantity combinations
- Document Rules: Document set rules clearly
Edge Cases
- Empty Set: Set must have at least one item
- Invalid Quantity Range:
maxQuantity < minQuantityis invalid - Zero Max Quantity: Not allowed (minimum is 1)
- Large Quantities: Keep maxQuantity reasonable for UX