discountUsageStats
Requires permission products:discount:read.
Returns how much a discount scheme has been used, taken from the organization's sales orders. Cancelled and deleted orders are left out. Fails if the scheme does not exist. Needs the discounts read permission.
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:
- GraphQL
- cURL
query DiscountUsageStats($schemeId: String!) {
discountUsageStats(schemeId: $schemeId) {
averageDiscountPerOrder
totalDiscountAmount
totalUsage
uniqueCustomers
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query DiscountUsageStats($schemeId: String!) {\n discountUsageStats(schemeId: $schemeId) {\n averageDiscountPerOrder\n totalDiscountAmount\n totalUsage\n uniqueCustomers\n }\n}",
"variables": {
"schemeId": "string"
}
}
EOF
Variables:
{
"schemeId": "string"
}
Response:
{
"data": {
"discountUsageStats": {
"averageDiscountPerOrder": 0,
"totalDiscountAmount": 0,
"totalUsage": 0,
"uniqueCustomers": 0
}
}
}
discountUsageStats(
schemeId: String!
): DiscountUsageStats!
Arguments
discountUsageStats.schemeId ● String! non-null scalar
The ID of the discount scheme.
Type
DiscountUsageStats object
How a discount scheme has been used.