Discount Codes

Queries and mutations for managing Discount Codes in the platform.

Queries

Query Discount Codes

QUERYdiscountCodes
Arguments
where​
String​
sort​
Array of String​
limit​
Int​
offset​
Int​

Get Discount Code

QUERYdiscountCode
Arguments
id​
String​

Queries with specified ID

key​
String​

Queries with specified key

Mutations

Create Discount Code

MUTATIONcreateDiscountCode
Arguments
draft​

Update Discount Code

MUTATIONupdateDiscountCode
Arguments
version​
Long​
actions​
id​
String​

Queries with specified ID

key​
String​

Queries with specified key

Delete Discount Code

MUTATIONdeleteDiscountCode
Arguments
version​
Long​
id​
String​

Queries with specified ID

key​
String​

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.

code​
String​
User-defined unique identifier of the DiscountCode added to the Cart to apply the related CartDiscounts.
key​
String​

User-defined unique identifier of the DiscountCode.

isActive​
Boolean​

Indicates if the DiscountCode is active and can be applied to the Cart.

maxApplications​
Long​

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.
maxApplicationsPerCustomer​
Long​

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.
cartPredicate​
String​

DiscountCode can only be applied to Carts that match this predicate.

applicationVersion​
Long​

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.

groups​
Array of String​

Groups to which the DiscountCode belongs to.

name​
String​

Name of the DiscountCode.

description​
String​

Description of the DiscountCode.

cartDiscounts​
Array 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.

referenceRefs​
Array of Reference​
nameAllLocales​
Array of LocalizedString​

Name of the DiscountCode.

descriptionAllLocales​
Array of LocalizedString​

Description of the DiscountCode.

custom​

Custom Fields of the DiscountCode.

applicationCount​
Long​

How many times this discount code was applied (only applications that were part of a successful checkout are considered)

storesRef​
Array 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.
stores​
Array 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.
cartDiscountRefs​
Array of Reference​
id​
String​

Unique identifier of the DiscountCode.

version​
Long​

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

offset​
Int​
count​
Int​
total​
Long​
exists​
Boolean​
results​
Array of DiscountCode​

Input types

DiscountCodeDraft

code​
String​

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.

name​

Name of the DiscountCode.

key​
String​

User-defined unique identifier for the DiscountCode.

description​

The description of the DiscountCode.

cartDiscounts​

Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

isActive​
Boolean​

Only active DiscountCodes can be applied to the Cart.

Default: true​
maxApplications​
Long​

Number of times the DiscountCode can be applied. If not set, the DiscountCode can be applied any number of times.

maxApplicationsPerCustomer​
Long​

Number of times the DiscountCode can be applied per Customer. If not set, the DiscountCode can be applied any number of times.

cartPredicate​
String​

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.
groups​
Array 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

cartDiscounts​

New value to set.

Change Groups

groups​
Array of String​

New value to set. An empty array removes the DiscountCode from all groups.

Change Is Active

isActive​
Boolean​
New value to set. Set to true to activate the DiscountCode for all matching Discounts.

Set Cart Predicate

cartPredicate​
String​

Value to set. If omitted, any existing value is removed.

Set Custom Field

name​
String​
Name of the Custom Field.
value​
String​
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

fields​
Array of CustomFieldInput​
typeKey​
String​
typeId​
String​

Set Description

description​

Value to set. If omitted, any existing value is removed.

Set Key

This action generates a DiscountCodeKeySet Message.
key​
String​

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

maxApplications​
Long​

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

maxApplicationsPerCustomer​
Long​

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

name​

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

validFrom​
Value to set that must be earlier than validUntil. If omitted, any existing value is removed.
validUntil​
Value to set that must be later than validFrom. If omitted, any existing value is removed.

Set Valid Until

validUntil​
Value to set that must be later than validFrom. If omitted, any existing value is removed.