In all supported API versions, and return an ACCESS_DENIED error when an app acting as a staff member without the permission adds a discount to a draft order. The mutations don’t save the draft order and return null for the mutation payload. Apps that rely only on userErrors for failure handling need to update their error handling.
What changed
When a request runs as a staff member who doesn’t have the and reject any change that adds discounts through the DraftOrderInput:
- Adding a discount code to
that the draft order doesn’t already have - Setting
to true on a draft order that doesn’t already accept automatic discounts
For any non-empty or counts as adding a discount because the draft order doesn’t exist yet.
In these cases, the mutation returns a top-level GraphQL error with the code ACCESS_DENIED and null for the mutation’s payload. The error doesn’t appear in userErrors.
Keeping or removing a draft order’s existing discounts still works.
Example
This request adds a discount code and turns on automatic discounts for an existing draft order:
mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {
draftOrderUpdate(id: $id, input: $input) {
draftOrder {
id
discountCodes
acceptAutomaticDiscounts
}
userErrors {
field
message
}
}
}{
"id": "gid://shopify/DraftOrder/276395349",
"input": {
"discountCodes": ["SUMMER10"],
"acceptAutomaticDiscounts": true
}
}If the staff member doesn't have the permission, the response is:
{
"errors": [
{
"message": "Access denied for draftOrderUpdate field. Required access: `write_draft_orders` access scope. Also: The user must have access to manage draft orders.",
"locations": [{ "line": 2, "column": 3 }],
"path": ["draftOrderUpdate"],
"extensions": {
"code": "ACCESS_DENIED",
"documentation": "https://shopify.dev/api/usage/access-scopes",
"requiredAccess": "`write_draft_orders` access scope. Also: The user must have access to manage draft orders."
}
}
],
"data": {
"draftOrderUpdate": null
}
} returns the same error, with in the message and path, and null for .
Who's affected
You’re affected if your app:
- Calls
oras a staff member, and - Expects to add discount codes or enable automatic discounts, and
- Doesn’t ensure that the staff member has the
permission
Requests that don’t act as a staff member, such as requests made with an offline access token, aren’t affected.
What to do
- Check the top-level
errorsarray, not just, for anACCESS_DENIEDerror fromor. - If your app needs to add discounts, ask the merchant to give the staff member the Apply discounts permission under Draft orders.