Loading...
Guides
Markdown
Customizable Products

Some products require user input before they can be added to a cartβ€”such as selecting a player on a jersey, choosing engraving text, or configuring attributes.

Diddo supports these through a structured customizations object returned in the /products response.

Your application should:

  1. Render the customization fields in the UI
  2. Capture the user’s selections or inputs
  3. Send those selections back when calling POST /cart/add

This guide explains how to interpret the customizations field and map it correctly to the cart request.

πŸ“˜

Dynamic Customization Schema
Customization schemas are returned directly with each product.
This allows clients to dynamically render configuration UI without hardcoding product-specific logic.


🧩 How Customizations Work

When a product supports customization, the /products endpoint returns a customizations array describing the required inputs.

Each customization object contains the information needed to render the UI and validate user input.

FieldDescription
keyUnique identifier for the customization
typeInput type (single_select, multi_select, text)
labelDisplay label for the UI
is_requiredWhether the user must provide a value
optionsAllowed values for select inputs
configValidation rules for text inputs

Example response from GET /products:

json

🎯 Customization Types

Select Inputs

Used when the user must choose from predefined options.

TypeDescription
single_selectChoose one option
multi_selectChoose multiple options

Each option contains:

FieldDescription
valueThe value sent back to the cart API
labelDisplay text for the UI
metadataOptional additional data (e.g. jersey number)

Example UI options:

LabelValue
Jordan, Michael23
Pippen, Scottie33
πŸ’‘

Important

Always send the value field from the option object when submitting a cart request.


Text Inputs

Used when the user enters custom text (e.g. engraving or jersey name).

Text customizations include validation rules in the config object.

Config FieldDescription
max_lengthMaximum allowed characters
patternRegex pattern used for validation

Example:

json

Client applications should validate these rules before submitting the cart request.


πŸ” Mapping Customizations to Cart Requests

When adding a product to a cart, send the selected values inside the customizations array.

The structure depends on the customization type.

Product typeCart fieldValue source
single_select / multi_selectvalueOne of options[].value
texttext_valueFree string entered by the user

Example POST /cart/add request for type text:

json

Example POST /cart/add request for type single_select / multi_select:

javascript

🧭 Implementation Flow

Typical client-side flow for customizable products:

1. Fetch products

plain

2. Check for customizations

If present, render UI inputs based on the schema.

3. Collect user input

Store the selected values using each customization key.

4. Add to cart

Send the selections when calling:

plain

⚠️ Important Notes

  • Only the value field should be sent to the cart API.
  • config is only populated for text customization types.
  • options is only populated for single_select/multi_select customization types.
  • Client-side validation should be applied for text fields before sending the request.

πŸ‘‰ Next: Working with Carts β†’