Product DiscountCodeApp Codes Not Working With Draft Orders

I noticed today while creating a draft order and trying to apply a product discount code created via discountCodeAppCreate that it doesn’t apply, despite working fine in checkout.

It seems to work fine with regular product discount codes created within the Shopify Discounts page though. The discount code shows in the dropdown list but when clicked it just runs a spinner for a moment and then nothing, not even an error.

I’m not sure if this is a bug or if there’s a setting I’m missing within the API.

The function is currently 2024-04, and the GraphQL Admin API being used is 2025-04.

@kyle, I haven’t been able to reproduce this problem and will need a little more information.

Would you be able to share the X-Request-Id from the response header of the request URL containing operation=CalculateDiscounts&type=mutation that should have occurred as soon as you clicked on the app discount in the drop-down list? Also the one for the request URL containing operation=DiscountCodes&type=query if it gets that far. I will be able to use your request ids to look into our logs and maybe determine what is happening.

Thanks for looking into this @Linda-Shopify, this is the response I get from operation=CalculateDiscounts&type=mutation:

{
    "data": {
        "draftOrderCalculate": {
            "calculatedDraftOrder": {
                "alerts": [],
                "discountCodes": [],
                "acceptAutomaticDiscounts": false,
                "platformDiscounts": [],
                "appliedDiscount": null,
                "warnings": [],
                "sessionToken": "8bac86de5ea6fe6b2ac479c0c261c30a",
                "currentMarketManager": "MERCHANT",
                "__typename": "CalculatedDraftOrder"
            },
            "userErrors": [],
            "__typename": "DraftOrderCalculatePayload"
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 18,
            "actualQueryCost": 14,
            "throttleStatus": {
                "maximumAvailable": 20000.0,
                "currentlyAvailable": 19986,
                "restoreRate": 1000.0
            }
        }
    }
}

After that request, all I see are requests to metrics and traces.

Thanks, @kyle!

"discountCodes": [] in this response tells me is that we were unable to apply the discount, but it’s still unclear why it’s not working.

Could you share the X-Request-Id value that should be in the HTTP response headers for this request? With that I can look deeper into our server logs.

Sorry I missed that part earlier, the request ID that comes:

x-request-id:
9fcc0d70-1cdf-40e1-a0cf-862f6bd998f3-1745520550

It still looks to be working for regular checkouts though when I apply the discount code there.

I’ve been able to reproduce the problem in my own shop and I believe it is a bug in our system.

Your app discount has a different title from its discount code. At checkout, you are able to enter the discount code, but on the draft order the drop-down shows (and attempts to apply) the discount title, which the server rejects because it is not a valid discount code.

I will open a ticket for this issue. In the mean time, you should be able to work around it by giving your app discount the same title and code.

1 Like