Applies to: Catalog API
Learn how to use item options to simplify the process of creating standard variants for catalog items.
Leveraging item options offers a more efficient strategy for application developers, especially when addressing inconsistencies in how sellers name product variations. By standardizing attributes like size and color, item options simplify the search process, allowing users to quickly find specific variations (such as a large red polo shirt) without navigating through poorly labeled or inconsistent entries (such as like Large red polo shirt, Red Polo shirt - LG, or Polo shirt: red large). This approach enhances usability and ensures a more seamless shopping experience.
The Catalog API includes several objects that enable efficient and standardized definitions of item variations in the seller's inventory. These objects include:
- Items - Generalized items, such as "Shirt".
- Item variation - Specific items for sale, such as "Polo shirt: Lg, red".
- Item options - Standardized attributes such as color, size, and style.
When creating item variations in the Square Dashboard, sellers have two options: using item options or the variation name model. In both cases, the item_variation_data.name
property is assigned a descriptive name. If item options are used, Square sets the variation name by combining the chosen option values into a comma-separated string and the item_variation_data.item_option_values
property references the selected options and values.
Important
When using item options, the CatalogItemVariation.name
includes only the option values, not the item's name (for example, "Large, Red" instead of "Polo shirt: Large, Red"). The item name should be set in the parent catalog item, such as "Polo shirt".
There are two strategies for defining shirt variations:
- Item variation name strategy - Add variation attributes to its name (such as "small red polo shirt").
- Item option strategy - Use item options to set variation attributes (such as "small", "red", and "polo").
When the variation name strategy is used, a seller might give variations inconsistent names, such as:
- "LG Red Camp Shirt".
- "Blue Polo shirt - small".
- "Yellow T-shirt: XL".
This can complicate searches within your application. For example, finding a blue polo shirt involves a text query like "blue polo shirt" to locate the relevant catalog objects. For more information, see Search for item variations by searchable attribute.
Item options streamline the creation of item variations by linking them to standardized attributes, such as these examples:
- Color - Options include "Red", "Green", and "Blue".
- Size - Options range from "Extra Large" to "Small".
- Style - Varieties such as "Polo", "Dress", and "Camp".
After your application creates a CatalogItemOption—such as "color" with predefined values—that option can be applied to define the color attribute for any new catalog items. Your application can also use catalog item options created by the seller in the Square Dashboard.
Using item options, a variation is automatically generated for every combination of option values. Each variation is linked to options and values (such as Red, Small, and Polo), eliminating the need for sellers to manually format individual descriptions. These examples (color, size, and style) are just that—examples. Your application can create any type of option with various values.
For information about querying by item option value, see Search for item variations using item options.
Item variations can be straightforward, defined by a single characteristic, or more complex, combining multiple characteristics to represent a composite variation.
In the following example, $35 polo shirts in three sizes and two colors are sold by a clothing retailer. To add these shirts to the catalog, six item variations are created. All the shirts have the same variation properties except for the variation name, which is unique to each variation.
- "Polo shirt, Red, Large"
- "Polo shirt, Red, Medium"
- "Polo shirt, Red, Small"
- "Polo shirt, Blue, Large"
- "Polo shirt, Blue, Medium"
- "Polo shirt, Blue, Small"
In the seller's item library and at the point of sale, items are organized alphabetically by name. If the naming of variations is inconsistent, the sorting order might appear illogical and confusing.
To add item variations to a catalog, create a CatalogItem
instance with a list of CatalogItemVariation
instances nested within the item through the variations
attribute on the CatalogItem
object. A variation is created for each combination of color and size.
Upsert catalog object