The commercetools platform provides a flexible data model that covers a wide range of use cases. However, there might be uses cases in which you wish to customize some resources in a way they fit your data model as close as possible.
With custom fields we give you the possibility to add fields to predefined resources, similar to AttributeDefinitions on ProductTypes. Please have a look at the resources that can currently be customized.
Before you can use a custom field on a resource you need to define the Type of the custom field you desire.
After the type definition you can set/read/update/delete the Custom field of the respective resources.
Please find attached the currently supported resources which can be enhanced using CustomFields.
|Resource||Resource type id|
|Carts||order (same as Orders)|
LineItems on Carts, Orders|
The representation to be sent to the server when creating a resource with custom fields.
type- ResourceIdentifier to a Type - Required
keyof the type to use.
fields- * - Optional
A valid JSON object, based on the FieldDefinitions of the Type.
For example, if you create the following Type:
In response to the request before the created category contains the following custom fields:
Query for CustomFields
You can query categories, for example, with the following predicate that filters for categories with the CustomField “description” that have the value “my description”: