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 Item
s that can be applied to aMenu Item
(e.g., "Pizza Toppings", "Coffee Milk Options", "Burger Sides").Variant Group Template
: A reusable blueprint forVariant Group
s, 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 Item
s 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 Item
s a customer must select from this group (e.g.,0
for optional,1
for required). - Max: The maximum number of
Variant Item
s a customer can select from this group. - Unique: A boolean indicating whether duplicate
Variant Item
s are allowed (e.g.,true
for "choose 2 different sauces",false
if they can select "Extra Cheese" twice). variantItems
: The list ofVariant Item
s 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 Group
s. 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 Item
s.
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 Item
s 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 Group
s created from this template. variantItems
: The predefined list ofVariant Item
s for this template.
When to use Variant Group Template
vs. Inline Variant Group
:
-
Use
Variant Group Template
when:- You have a common set of options that will be applied to many
Menu Item
s. - 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 Group
s). - 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 Group
is unique to a singleMenu Item
. - The options are highly specific and unlikely to be reused.
- You need complete control over the
Variant Group
without 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 Item
s: First, you create individualVariant Item
s (e.g., "Extra Pepperoni", "Gluten-Free Crust"). - Create
Variant Group Template
s (Optional but Recommended): If you have common groups of variants, create templates (e.g., "Pizza Crusts", "Pizza Toppings"). - Assign
Variant Group
s toMenu Item
s: When editing aMenu Item
, you can:- Create a new
Variant Group
inline: Define a new group and addVariant Item
s directly to it. This group is specific to thisMenu Item
. - Create a
Variant Group
from aVariant Group Template
: Select an existing template, and a newVariant Group
will 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.