Applies to: Catalog API
Learn how to use Item Options to simplify the process of creating many 'standard' variants for catalog items.
Utilizing item options can be a more effective strategy for application developers, particularly when dealing with sellers who lack consistency in naming item variations. By standardizing attributes such as size and color, item options streamline the search process. This approach enables users to easily locate specific product variations, such as a large, red polo shirt, without the confusion of sifting through inconsistently named entries like 'Large, red polo shirt', 'Red Polo shirt - LG', or 'Polo shirt: red, large'.
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, e.g., "Shirt"
- Item variation - Specific items for sale, e.g., "Polo shirt: Lg, red"
- Item options - Standardized attributes like 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 instance, it would be "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 (e.g., "small red polo shirt").
- Item option strategy - Use item options to set variation attributes (e.g., "small", "red", "polo").
When the variation name strategy is used, a seller might give variations inconsistent names, as shown in these examples:
- "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 would involve a text query like "blue polo shirt" to locate the relevant catalog objects. For guidance on using a text query, 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", "Blue", etc.
- Size - Options range from "Extra Large" to "Small".
- Style - Varieties like "Polo", "Dress", "Camp", etc.
Once your application creates a CatalogItemOption like "color" with its values, that option can be used to define color for any new catalog items. Your application can also use catalog item options created by the seller in the Square Dashboard.
With item options, a variation is created for every combination of option values. Each variation is linked to options and values (like Red, Small, Polo), so sellers don't have to manually format each description. The examples given (color, size, style) are just that—examples. Your application can create any type of option with various values.
For details on querying by item option value, see Search for item variations using item options.
Item variations can be simple, featuring just one characteristic, or composite, which combine multiple characteristics.
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 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 may appear illogical and confusing to the user.
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