Understanding Variants
A comprehensive guide to understanding and utilizing variants in Diinr.
Understanding Variants in Diinr
Variants in Diinr allow you to offer customizable options for your menu items. This is crucial for items that come in different sizes, flavors, or with various add-ons (e.g., a pizza with different toppings, a coffee with milk options, or a burger with optional sides).
Diinr utilizes three key models to manage variants:
Variant Item: Represents an individual customizable option (e.g., "Extra Cheese", "Large Size", "Almond Milk").Variant Group: A collection ofVariant Items that can be applied to aMenu Item(e.g., "Pizza Toppings", "Coffee Milk Options", "Burger Sides").Variant Group Template: A reusable blueprint forVariant Groups, allowing you to define common sets of options that can be applied to multiple menu items.
Variant Item
A Variant Item is the most granular component of the variant system. It defines a single choice that a customer can make. Each Variant Item has:
- Name: The display name of the variant (e.g., "Pepperoni", "Small", "Decaf").
- Description: An optional description for the variant.
- Price: An additional cost associated with selecting this variant. This price is added to the base price of the
Menu Item. - Tags: For categorization and filtering.
Example Use Cases:
- Pizza Toppings: "Mushrooms", "Onions", "Extra Cheese"
- Coffee Sizes: "Small", "Medium", "Large"
- Drink Options: "Coke", "Diet Coke", "Sprite"
Variant Group
A Variant Group is a collection of Variant Items that are presented together as a set of choices for a Menu Item. When you add a Variant Group to a Menu Item, you define how customers can interact with these options.
Key properties of a Variant Group:
- Name: The name of the group (e.g., "Choose Your Toppings", "Select Your Size").
- Description: An optional description for the group.
- Min: The minimum number of
Variant Items a customer must select from this group (e.g.,0for optional,1for required). - Max: The maximum number of
Variant Items a customer can select from this group. - Unique: A boolean indicating whether duplicate
Variant Items are allowed (e.g.,truefor "choose 2 different sauces",falseif they can select "Extra Cheese" twice). variantItems: The list ofVariant Items belonging to this group.showPriceAfter: A boolean to control whether the price of the variant item is shown after the variant name.
Example Use Cases:
- Pizza Toppings Group: Min: 0, Max: 5, Unique: true (customers can choose up to 5 different toppings).
- Coffee Size Group: Min: 1, Max: 1, Unique: true (customers must choose exactly one size).
- Burger Patty Group: Min: 1, Max: 2, Unique: false (customers can choose one or two patties, even the same type twice).
Variant Group Template
A Variant Group Template acts as a blueprint for Variant Groups. If you have several menu items that share the same set of customizable options (e.g., all your pizzas use the same set of cheese toppings), you can define a Variant Group Template once and reuse it across multiple Menu Items.
This saves time and ensures consistency. When you create a Variant Group from a Variant Group Template, the Variant Group inherits all the properties and Variant Items from the template. You can then further customize the Variant Group if needed, but the template provides a strong starting point.
Key properties of a Variant Group Template:
- Name: The name of the template (e.g., "Standard Toppings", "Drink Options").
- Description: An optional description.
- Min/Max/Unique: These properties are inherited by
Variant Groups created from this template. variantItems: The predefined list ofVariant Items for this template.
When to use Variant Group Template vs. Inline Variant Group:
-
Use
Variant Group Templatewhen:- You have a common set of options that will be applied to many
Menu Items. - You want to ensure consistency across multiple items.
- You anticipate needing to update the options for many items simultaneously (updating the template will propagate changes to all linked
Variant Groups). - Examples: Standard drink choices, common side dishes, universal cooking preferences.
- You have a common set of options that will be applied to many
-
Use Inline
Variant Group(without a template) when:- The
Variant Groupis unique to a singleMenu Item. - The options are highly specific and unlikely to be reused.
- You need complete control over the
Variant Groupwithout affecting other items. - Examples: A special limited-time offer with unique add-ons, a highly customized dish with one-off options.
- The
How Variants Work Together
- Define
Variant Items: First, you create individualVariant Items (e.g., "Extra Pepperoni", "Gluten-Free Crust"). - Create
Variant Group Templates (Optional but Recommended): If you have common groups of variants, create templates (e.g., "Pizza Crusts", "Pizza Toppings"). - Assign
Variant Groups toMenu Items: When editing aMenu Item, you can:- Create a new
Variant Groupinline: Define a new group and addVariant Items directly to it. This group is specific to thisMenu Item. - Create a
Variant Groupfrom aVariant Group Template: Select an existing template, and a newVariant Groupwill be created based on that template. This group is linked to the template, meaning changes to the template can affect this group.
- Create a new
This flexible structure allows you to manage simple add-ons to complex, multi-option customizable items efficiently.