When a staff member without the discount permission tries to add a discount, draftOrderCreate and draftOrderUpdate fail and save nothing. The error is in the top-level errors array, so apps that only check userErrors will miss it.
What changed
The mutation returns a null payload and the draft order is not saved. Two changes made through DraftOrderInput count as adding a discount:
- Adding a code to
discountCodesthat the draft order doesn’t already have - Setting
acceptAutomaticDiscountstotruewhen it isn’t already true
For
draftOrderCreate, any non-emptydiscountCodesoracceptAutomaticDiscounts: truecounts, because the draft order doesn’t exist yet. Keeping or removing existing discounts still works.
Example
A draftOrderUpdate that adds SUMMER10 and enables automatic discounts is rejected for a staff member without the permission.
{
"errors": [
{
"message": "Access denied for draftOrderUpdate field. …",
"path": ["draftOrderUpdate"],
"extensions": { "code": "ACCESS_DENIED" }
}
],
"data": { "draftOrderUpdate": null }
}Shape based on the fields named in the changelog. draftOrderCreate returns the same error with its own name in the message and path.
Who’s affected
Your app is affected if all three are true:
- It calls
draftOrderCreateordraftOrderUpdateas a staff member - It needs to add discount codes or enable automatic discounts
- It doesn’t confirm the staff member has
apply_discounts_to_draft_orders
Not affected: requests that don’t act as a staff member, such as those using an offline access token.
What to do
-
Handle the top-level error
Check the top-level
errorsarray forACCESS_DENIEDfrom either mutation, not justuserErrors. -
Ask the merchant to grant the permission
If the app must add discounts, the merchant grants Apply discounts under Draft orders for that staff member.
Scopes and identifiers
| Item | Value |
|---|---|
| Required access | write_draft_orders scope + permission to manage draft orders |
| Permission | apply_discounts_to_draft_orders |
| Mutations | draftOrderCreate, draftOrderUpdate |
| Input fields | DraftOrderInput.discountCodes, DraftOrderInput.acceptAutomaticDiscounts |
| Error code | ACCESS_DENIED |