I successfully built a discount function app that works exactly the way i want, following the tutorial “Build a Discount Function” and by making some small changes to the code in the files within the src folder and in shopify.extension.toml.
I ran all the necessary procedures and created an automatic discount in my dev store using GraphiQL (Admin API) in my browser (while running “shopify app dev”).
I downloaded the discount function app to my production store, and to create the automatic discount, I also downloaded the Shopify GraphiQL App to make it the same as in the dev store. Running the exact same mutation:
mutation {
discountAutomaticAppCreate(
automaticAppDiscount: {
title: “Bundle Lab OFFER”
functionHandle: “discount-function-js”
discountClasses: [ORDER, SHIPPING]
startsAt: “2025-01-01T00:00:00”
}
)
{
automaticAppDiscount {
discountId
}
userErrors {
field
message
}
}
}
It gave me the following errors:
{
"data": {
"discountAutomaticAppCreate": {
"automaticAppDiscount": null,
"userErrors": [
{
"field": [
"automaticAppDiscount"
],
"message": "Function not found. Ensure that it is released in the current app (2315872), and that the app is installed."
…..}
The paradox is that I also downloaded the Shopify GraphiQL App on the dev store, and while the same mutation created the automatic discount correctly from GraphiQL (Admin API) in my browser, the Shopify GraphiQL App showed me the same error that I was getting on the production store (the error is shown above).
What could be wrong that I can’t create an automatic discount?
The app installed successfully on the store.
The function released
I’m using the correct function handle.
I’m using the correct API version.