Skip to main content

appCreateDiscountCode

Requires permission products:discount:create.

Create a discount code from an installed app, for named customers. The server picks the code (APP-<HANDLE>-<random>) and fixes the scheme: bound to those customers, applied only when a buyer enters the code, percent only, switched off when the app is uninstalled. Needs write_discount_codes.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation AppCreateDiscountCode($input: AppCreateDiscountCodeInput!) {
appCreateDiscountCode(input: $input) {
id
code
name
customerIds
isActive
percentageValue
}
}

Variables:

{
"input": {
"customerIds": [
"id"
],
"name": "string",
"percentageValue": 0
}
}

Response:

{
"data": {
"appCreateDiscountCode": {
"id": "id",
"code": "string",
"name": "string",
"customerIds": [
"id"
],
"isActive": true,
"percentageValue": 0
}
}
}
appCreateDiscountCode(
input: AppCreateDiscountCodeInput!
): AppDiscountCode!

Arguments​

appCreateDiscountCode.input ● AppCreateDiscountCodeInput! non-null input​

The code's customers and percentage.

Type​

AppDiscountCode object​

A discount code an installed app created.