Discount Code import
Learn about the headers and values supported for importing Discount Codes.
Supported headers and values
You can update a Discount Code only if it has a key
. You can assign a key
to a Discount Code either from the Discount code list or by using the Discount Codes API.
When updating Discount Codes, include only the headers and values for the fields you are updating.
Header | Value | Required/Optional |
---|---|---|
key | A unique identifier for the Discount Code that is imported. The key must only include letters, numbers, underscores (_), or dashes (-). If a Discount Code with the provided key exists in the Project, it is updated with the provided value—otherwise, a new entry is created. | Required |
name.en | A localized name for the Discount Code. You can provide multiple headers to include different languages values. For headers ending with | Optional |
description.en | A localized description for the Discount Code. You can provide multiple headers to include different languages values. For headers ending with | Optional |
code | The code that is added to the Cart to apply the related Cart Discounts. An existing code cannot be updated or modified. | Required, when creating a new Discount Code |
cartDiscounts | The key of the Cart Discount to apply when you add the Discount Code to the Cart. To assign multiple Cart Discounts, separate the keys with a semicolon. | Required, when creating a new Discount Code. |
cartPredicate | The Discount Code can only be applied to Carts that match this discount predicate. | Optional |
isActive | If true , the Discount Code can be applied to Carts. If false , the Discount Code cannot be used. | Optional. If not included, the default value is true . |
maxApplications | Number of times the Discount Code can be applied. If not set, the Discount Code can be applied any number of times. | Optional |
maxApplicationsPerCustomer | Number of times the Discount Code can be applied per Customer. If not set, the Discount Code can be applied any number of times. | Optional |
groups | A semicolon-separated list of tags used for grouping and organizing Discount Codes. | Optional |
validFrom | The date and time from which the Discount Code is effective. Must be earlier than validUntil . | Optional |
validUntil | The date and time until which the Discount Code is effective. Must be later than validFrom . | Optional |
custom.type.key | A unique identifier for the Type referenced in a Custom Field. | Required, when importing Custom Fields. |
custom.type.typeId | type | Required, when custom.type.key is provided. |
custom.fields.{nameOfCustomField} | Replace {nameOfCustomField} with the name of the Custom Field, as defined in the respective FieldDefinition. The value must conform to the FieldType of the Custom Field. For more information, see Custom Fields. | Optional |
Custom Fields
Replace {nameOfCustomField}
with the name of the Custom Field, as defined in the respective FieldDefinition. The name of the Custom Field is case-sensitive.
When importing LocalizedString Custom Fields, provide headers and values for each language. For example, for English and German, provide custom.fields.{nameOfCustomField}.en
and custom.fields.{nameOfCustomField}.de
respectively.
When importing boolean Custom Fields, the values must be lowercase.
For Money Custom Fields, provide the following additionally:
Header | Value | Required/Optional |
---|---|---|
custom.fields.{nameOfCustomField}.currencyCode | An ISO 4217-compliant currency code such as USD , EUR , or GBP . | Required |
custom.fields.{nameOfCustomField}.centAmount | An amount in the smallest indivisible unit for a currency. For example, 500 can be equal to USD 5.00 or JPY 500. | Required |
custom.fields.{nameOfCustomField}.type | centPrecision | Required |
custom.fields.{nameOfCustomField}.fractionDigits | The number of digits after the decimal separator. For example, 2 for USD or 0 for JPY. | Required |
Sets of Custom Fields
For sets of simple Custom Fields (such as numbers, text, and booleans) the header would contain the Custom Fields name, and value would be a semicolon-separated list. The following example demonstrates how to import sets of text and numbers.
custom.fields.colorCombination | custom.fields.numberSet |
---|---|
red;green;blue | 10;5;32 |
Sets of complex Custom Fields
For sets of complex values (such as localized text, references, and money), you can import single set values by defining the index and the subfields in the header. The following example demonstrates how to update the first entry of a set of Custom Fields called relatedCategories
that references Categories.
custom.fields.relatedCategories.1.key | custom.fields.relatedCategories.1.typeId |
---|---|
red-shirts | category |
To update the second entry, include the same headers but change 1
to 2
.
You can also import multiple set values by using *
instead of a number. With this approach, the values of set items are entered into sequential rows.
The following example demonstrates how to create a set of Custom Fields called relatedCategories
with four entries.
custom.fields.relatedCategories.*.key | custom.fields.relatedCategories.*.typeId |
---|---|
red-shirts | category |
summer-collection | category |
new-arrivals | category |
red-accessories | category |
Delete data
When updating resources, you can remove data for optional fields. To remove data, in the CSV file, enter [DELETE]
as the value for the header (field). When deleting values for reference fields or multi-value fields, you must add a new column with the common prefix as the header, and enter [DELETE]
as the value.
For example, to delete data for a Custom Field—that is custom.fields.customField1
in the CSV file—add a new column, custom.fields.customField1
, with [DELETE]
as its value.