Queries and mutations for managing Discount Codes in the platform.
Queries
Query Discount Codes
| Arguments | |
|---|---|
whereString | |
sortArray of String | |
limitInt | |
offsetInt | |
Get Discount Code
| Arguments | |
|---|---|
idString | Queries with specified ID |
keyString | Queries with specified key |
Mutations
Create Discount Code
Update Discount Code
| Arguments | |
|---|---|
versionLong | |
actionsArray of DiscountCodeUpdateAction | |
idString | Queries with specified ID |
keyString | Queries with specified key |
Delete Discount Code
| Arguments | |
|---|---|
versionLong | |
idString | Queries with specified ID |
keyString | Queries with specified key |
Output types
DiscountCode
With discount codes it is possible to give specific cart discounts to an eligible amount of users. They are defined by a string value which can be added to a cart so that specific cart discounts can be applied to the cart.
codeString | User-defined unique identifier of the DiscountCode added to the Cart to apply the related CartDiscounts. |
keyString | User-defined unique identifier of the DiscountCode. |
isActiveBoolean | Indicates if the DiscountCode is active and can be applied to the Cart. |
maxApplicationsLong | Number of times the DiscountCode can be applied. DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count. If
maxApplicationsPerCustomer is set, each application also counts toward this limit.This field does not limit discount applications for Orders created from a Recurring Order. |
maxApplicationsPerCustomerLong | Number of times the DiscountCode can be applied per Customer (anonymous Carts are not supported). Each use also counts toward the
maxApplications limit.DiscountCode application is counted at the time of Order creation or edit. However, Order cancellation or deletion does not decrement the count. This field does not limit discount applications for Orders created from a Recurring Order. |
cartPredicateString | DiscountCode can only be applied to Carts that match this predicate. |
applicationVersionLong | Used and managed by the API and must not be used in customer logic. The value can change at any time due to internal and external factors. |
groupsArray of String | Groups to which the DiscountCode belongs to. |
nameString | Name of the DiscountCode. |
descriptionString | Description of the DiscountCode. |
cartDiscountsArray of CartDiscount | Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied. |
validFrom | Date and time (UTC) from which the DiscountCode is effective. |
validUntil | Date and time (UTC) until which the DiscountCode is effective. |
referenceRefsArray of Reference | |
nameAllLocalesArray of LocalizedString | Name of the DiscountCode. |
descriptionAllLocalesArray of LocalizedString | Description of the DiscountCode. |
custom | Custom Fields of the DiscountCode. |
applicationCountLong | How many times this discount code was applied (only applications that were part of a successful checkout are considered) |
storesRefArray of KeyReference | Reference to the Stores the DiscountCode is associated with, derived from the
stores field of each referenced CartDiscount.The value of this field is eventually consistent. |
storesArray of Store | Reference to the Stores the DiscountCode is associated with, derived from the
stores field of each referenced CartDiscount.The value of this field is eventually consistent. |
cartDiscountRefsArray of Reference | |
idString | Unique identifier of the DiscountCode. |
versionLong | Current version of the DiscountCode. |
createdAt | Date and time (UTC) the DiscountCode was initially created. |
lastModifiedAt | Date and time (UTC) the DiscountCode was last updated. |
createdBy | IDs and references that created the DiscountCode. |
lastModifiedBy | IDs and references that last modified the DiscountCode. |
Discount Code Query Result
offsetInt | |
countInt | |
totalLong | |
existsBoolean | |
resultsArray of DiscountCode |
Input types
DiscountCodeDraft
codeString | User-defined unique identifier for the DiscountCode that can be added to the Cart to apply the related CartDiscounts. It cannot be modified after the DiscountCode is created. |
nameArray of LocalizedStringItemInputType | Name of the DiscountCode. |
keyString | User-defined unique identifier for the DiscountCode. |
descriptionArray of LocalizedStringItemInputType | The description of the DiscountCode. |
cartDiscountsArray of ResourceIdentifierInput | Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart. |
isActiveBoolean | Only active DiscountCodes can be applied to the Cart. Default:true |
maxApplicationsLong | Number of times the DiscountCode can be applied. If not set, the DiscountCode can be applied any number of times. |
maxApplicationsPerCustomerLong | Number of times the DiscountCode can be applied per Customer. If not set, the DiscountCode can be applied any number of times. |
cartPredicateString | DiscountCode can only be applied to Carts that match this predicate. |
custom | Custom Fields for the DiscountCode. |
validFrom | Date and time (UTC) from which the DiscountCode is effective. Must be earlier than validUntil. |
validUntil | Date and time (UTC) until which the DiscountCode is effective. Must be later than validFrom. |
groupsArray of String | Groups to which the DiscountCode will belong to. Default:[] |
DiscountCodeUpdateAction
changeCartDiscounts | |
changeGroups | |
changeIsActive | |
setCartPredicate | |
setCustomField | |
setCustomType | |
setDescription | |
setKey | |
setMaxApplications | |
setMaxApplicationsPerCustomer | |
setName | |
setValidFrom | |
setValidFromAndUntil | |
setValidUntil |
Update actions
Change Cart Discounts
cartDiscountsArray of ResourceIdentifierInput | New value to set. |
Change Groups
groupsArray of String | New value to set. An empty array removes the DiscountCode from all groups. |
Change Is Active
isActiveBoolean | New value to set. Set to true to activate the DiscountCode for all matching Discounts. |
Set Cart Predicate
cartPredicateString | Value to set. If omitted, any existing value is removed. |
Set Custom Field
nameString | Name of the Custom Field. |
valueString | If value is absent or null, this field will be removed if it exists.
Removing a field that does not exist returns an InvalidOperation error.
If value is provided, it is set for the field defined by name. |
Set Custom Type
fieldsArray of CustomFieldInput | |
type | |
typeKeyString | |
typeIdString |
Set Description
descriptionArray of LocalizedStringItemInputType | Value to set. If omitted, any existing value is removed. |
Set Key
keyString | Value to set. If omitted, any existing value is removed. If the value is used by another Discount Code, a DuplicateField error is returned. |
Set Max Applications
maxApplicationsLong | Value to set. If omitted, any existing value is removed and the DiscountCode can be applied any number of times. If
maxApplicationsPerCustomer is set, each application also counts toward this limit.This field does not limit discount applications for Orders created from a Recurring Order. |
Set Max Applications Per Customer
maxApplicationsPerCustomerLong | Value to set. If omitted, any existing value is removed and the DiscountCode can be applied any number of times. Each use also counts toward the
maxApplications limit.This field does not limit discount applications for Orders created from a Recurring Order. |
Set Name
nameArray of LocalizedStringItemInputType | Value to set. If omitted, any existing value is removed. |
Set Valid From
validFrom | Value to set that must be earlier than validUntil. If omitted, any existing value is removed. |
Set Valid From And Until
Set Valid Until
validUntil | Value to set that must be later than validFrom. If omitted, any existing value is removed. |