I am creating discount app and using Shopify Functions Product Discount API to create discounts. I have used this template ( https://github.com/Shopify/function-examples/tree/main/sample-apps/discounts-tutorial ). It works well and created the app with product discounts extension. To create a discount itself it uses admin GraphQL API with discountAutomaticAppCreate mutation. All works when creating discounts from the app template. However, when I try to send the same request from Postman I am getting the following error:
It looks like API does not see my function. I checked the functionId, it’s correct.
I want to change the project template to a custom one, because of inconvenience and other problems. That is why I cannot continue using this template.
P.S. I tried to send the request from another app’s backend (working app) and received the same error.
All requests are done to the store with checkout extensibility preview.
Currently an app can only reference its own functions. That is, when invoking discountAutomaticAppCreate, the API Key used must belong to the same app as the function.
In the case of Postman then, be sure you are using an offline access token for the same app.
I have the same problem when i try save a order discount, my app works fine in development store but i dont understand why when install on production store i get “automaticAppDiscount.functionId Function not found”, i tried create others apps and in development store works great but on production I get the same error.
I am installing the app to production by install link.
The SHOPIFY_API_KEY is correct.
My question is: what do i have to do for my app works fine on production store.
@RickyMagana This may also indicate that you are attempting to use a custom app with a non-Plus shop. Functions can only be used in custom/single-shop apps with a Plus subscription.
When I move it to the production store, running the GraphiQL query to retrieve the functions in step 4, does not return the function, even though it is installed.
Using this access token, I can now run a graphql, which lists out the function correctly, but when I try to add the discountAutomaticAppCreate via graphql using the same access token, it returns ‘function not found’.
The token has write_discounts scope.
Any idea what I’m doing wrong?
Does the store need to be on a PLUS plan for this to work?
“Functions can only be used in custom/single-shop apps with a Plus subscription”
This kind of suggests that they do, but I have other (cart-validation) functions working with a single shop/custom setup…???
mutation {
discountAutomaticAppCreate(automaticAppDiscount:{
startsAt: “2024-09-25”,
title: “Order Discount”,
functionId: “4e215005-26ae-486b-b310-54827cdd4cf7”
}) {
automaticAppDiscount {
discountId
}
userErrors {
code
message
}
}
}
This function works in my development test store and I get an internal server error in the production area. I wonder if the Order Discount Function is available only for Shopify Plus subscribers.
Here is the error I encountered during this mutation operation :
{
“errors”: [
{
“message”: “Internal error. Looks like something went wrong on our end.\nRequest ID: 690f9175-1aaf-4b24-8caf-5c79c7a2ff72-1727308714 (include this in support requests).”,
“extensions”: {
“code”: “INTERNAL_SERVER_ERROR”,
“requestId”: “690f9175-1aaf-4b24-8caf-5c79c7a2ff72-1727308714”
}
}
]
}