createDiscount
Creates a single discount code with a code string that you choose yourself.
Shoppers redeem the code with applyDiscountCode or applyCodeToNewCart. To create
many codes with randomly generated code strings in one step, use generateDiscountCodes
instead.
BenefitInput is required and must set exactly one of cartPercentage, itemPercentage or fixedDiscount;
setting none of them responds with an error.
Every entry of CreateDiscountInput.constraints must likewise set exactly one of time, redemptions or
ticketTypes. An entry with no field set, or a ticket type ID that does not exist, responds with an
error. A discount can carry at most one constraint of each kind, so passing two entries of the same
kind responds with an error as well.
The code must be unique among the company's active discounts. Reusing a code that is currently taken
responds with a duplicate error whose message is translated into the language given in the locale
argument, defaulting to English. Company.hasActiveDiscountCode tells you upfront whether a code is
still free.
The new discount starts out active and is resolved as CreateDiscountPayload.discount. To change its
constraints later, use changeDiscountConstraints.
mutation CreateSummerCode($companyId: ID!) { createDiscount( input: { companyId: $companyId code: "SUMMER25" benefit: { cartPercentage: 25 } constraints: [{ redemptions: 100 }] } locale: "de-AT" ) { discount { id code isActive } } }mutation CreateSummerCode($companyId: ID!) { createDiscount( input: { companyId: $companyId code: "SUMMER25" benefit: { cartPercentage: 25 } constraints: [{ redemptions: 100 }] } locale: "de-AT" ) { discount { id code isActive } } }
Authorization is required: you must be allowed to manage the discounts of the given company. A company ID that does not exist responds with a not-found error.
Arguments
| Argument | Description | Type |
|---|---|---|
| input | CreateDiscountInput! | |
| locale | Locale |
Type
This field resolves to CreateDiscountPayload, which has the following fields: