Enable Product Customization with Modifiers

When selling certain products, a seller might want to give the buyer choices to add selected modifications. For example, when ordering a cheeseburger, the buyer can choose to add a specialty cheese of gorgonzola or pecorino for an additional cost. In this case, the specialty cheese is modeled by CatalogModifier in the Square catalog. Another example of product customization is selling T-shirts with custom printing of buyer-selected text.

Link to section

Understand the modifier data models

The Square catalog supports two types of modifiers: list-based modifiers and text-based modifiers.

Text-based modifiers are currently in Beta, while list-based modifiers are in General Availability.

Link to section

List-based modifier data model

The list-based modifier is also referred to as non-text-based modifiers. The specialty cheese example describes non-text-based modifiers, which are represented by a list of CatalogModifier objects contained in a CatalogModifierList object. The data model of list-based modifiers is of the following format:

With list-based modifiers, the CatalogModifierList object contains a non-empty list of CatalogModifier objects.

Link to section

Text-based modifier data model

An example of a text-based modifier is buyer-selected text printed on a T-shirt, when a seller sells T-shirts with custom printing. However, it's represented directly by a CatalogModifierList object. The data model of the text-based modifier is of the following form:

{ "type": "MODIFIER_LIST", "id": "{{Square-generated unique string}}", ... "modifier_list_data": { "name": "{{The modifier's name}}", "selection_type": "SINGLE", "modifier_type": "TEXT", "max_length": {{Maximum unicode points of the modifier's text}}, "text_required": {{Whether the modifier's text can be empty (false) or not (true}} "internal_name": "{{Notes for the seller about this transaction}}" } }

Unlike list-based modifiers, a text-based modifier is represented by the CatalogModifierList object itself and doesn't incur any extra cost. The selection_type is always SINGLE. Any attempt to set the other selection type is ignored.

To better appreciate the differences between list-based modifiers and a text-based modifier, it might be helpful to view the CatalogModifierList object for a text-based modifier as containing a single modifier as described by properties specific to text-based modifiers. The CatalogModifierList object for list-based modifiers, on the other hand, contains a list of CatalogModifier instances each of which is a non-text-based modifier.

Link to section

Enable modifiers on an item

To enable customization to a product offering, supported modifiers must be created and then added to the associated product item in the catalog. When enabled, the modifiers can be presented for the buyer to choose when the product item is ordered.

Creating modifiers and adding them to an item involves calling the Catalog API. Presenting product modifications to the buyer is part of the ordering process and built into buyer-facing client applications, such as Square Point of Sale or third-party applications, that are integrated with the Orders API.

In this topic, you learn how to enable list-based and text-based modifiers on items.

Link to section

Enable list-based modifiers on an item

To enable list-based modifiers, call the UpsertCatalogObject or BatchUpsertCatalogObjects endpoint to do the following:

  • Create a CatalogModifierList object with the modifier_type attribute set to LIST. Assign a non-empty list of CatalogModifier objects on the modifiers property.
  • Create a CatalogItem object (if it doesn't exist already), reference the modifier list, and specify within the modifier_list_info attribute of the item how the modifier can be selected at the time of sale.

When multiple catalog objects are created, UpsertCatalogObject must be invoked one object at a time, while BatchUpsertCatalogObjects can be invoked for all the required catalog objects in one call.

Request: Add two cheese modifiers to a cheeseburger

The following example invokes BatchUpsertCatalogObjects to perform the following tasks:

  • Create a CatalogModifierList object containing a list of two CatalogModifier objects for the gorgonzola cheese and pecorino cheese modifiers.
  • Create a CatalogItem object for a cheeseburger item with the two cheese modifiers included as optional add-ons for the buyer to choose from.

Batch upsert catalog objects

The modifiers have their own pricing. In this example, each costs an additional 1 US dollar, namely 100 cents. The MULTIPLE selection type declared within the CatalogModifierList object means that this cheeseburger can have more than one type of cheese added to it. If the selection type is SINGLE, the cheeseburger can have gorgonzola or pecorino cheese added to it, but not both.

The number of cheeses a buyer can choose when ordering the cheeseburger is specified by the min_selected_modifiers and max_selected_modifiers values within the modifier_list_info property of the CatalogItem object. In this example, because min_selected_modifiers=0 and max_selected_modifiers=2, the buyer can choose 0, 1, or 2 cheeses when ordering the cheeseburger and be charged $7, $8, or $9, respectively. For a $9 cheeseburger, it can have one of the following cheese options:

  • One gorgonzola and one pecorino
  • Two portions of gorgonzola
  • Two portions of pecorino

If the quantity is unspecified, min_selected_modifiers or max_selected_modifiers defaults to -1. This indicates that the selections are unlimited.

Note

The actual quantity of modifiers selected by a buyer is order-specific and not recorded in the catalog.

Response: Add two cheese modifiers to a cheeseburger

The successful response returns a payload similar to the following:

Link to section

Enable a text-based modifier on an item

To enable text-based modifiers on an item, call the UpsertCatalogObject or BatchUpsertCatalogObjects endpoint to perform the following tasks:

  • Create a CatalogModifierList object with the modifier_type attribute set to TEXT. Don't set the modifiers list property.
  • Create a CatalogItem object, if it doesn't exist already, while referencing the modifier list within the modifier_list_info attribute of the item.

When multiple catalog objects are created, UpsertCatalogObject must be invoked for one object at a time, while BatchUpsertCatalogObjects can be invoked for all the required catalog objects in one call.

For a text-based modifier, there's no need to specify min_selected_modifiers and max_selected_modifiers to define the selectable quantity because they don't apply to any text-based modifier.

Request: Enable a text-based modifier on an item

The following example invokes BatchUpsertCatalogObjects to perform the following tasks:

  • Create a text-based modifier as presented by a CatalogModifierList object with properties specific text-based modifiers.
  • Create a CatalogItem object for a custom-print T-shirt item with buyer-supplied text printed on the front of the T-shirt.

Batch upsert catalog objects

In the specification of the text-based modifier (namely, the CatalogModifierList object), the modifier_list_data contains two properties specific to text-based modifiers. This is in addition to certain properties that also apply to the CatalogModifierList object containing a list of CatalogModifier objects each of which is a non-text-based modifier.

  • max_length - Sets the limit of the buyer-supplied text, with 150 unicode points as the default value.
  • text_required - Determines whether buyer-supplied text can be empty (false) or not (true). The default value is false. When an empty text is allowed, the seller might opt to skip printing the text or use pre-selected text, according to the business plan.

It's more likely to expect that the internal_name attribute is also used to specify internal instructions or supplemental descriptions for how custom printing should be done.

If the custom-print T-shirt can have two texts printed on the front or back of a T-shirt, a Back Print catalog object of the MODIFIER_LIST type can be inserted after the Front Print text-based modifier.

{ "id": "#modifier_list_back", "type": "MODIFIER_LIST", "modifier_list_data": { "modifier_type": "TEXT", "name": "Back Print", "max_length": 150, "text_required": false, "internal_name": "Use purple color" } },

In turn, the modifier_list_info list under item_data needs to be updated to the following:

"modifier_list_info": [ { "modifier_list_id": "#modifier_list_front", "enabled": true }, { "modifier_list_id": "#modifier_list_back", "enabled": true } ],

With this addition, the buyer must provide text for the front when ordering the T-shirt, but might choose to add or not add text for the back.

Response: Enable a test-based modifier on an item

The successful response contains a payload similar to the following:

Link to section

See also