Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Hello,
I'm using graphQL with discountAutomaticAppCreate query but it keeps saying that my function is not found.
What is the functionId and where do I find it?
Solved! Go to the solution
This is an accepted solution.
When you are done with coding of function you have to deploy the app on to your store. Once you have deployed it. In you .env file the app will create a function id of that Shopify Function and then you can use discountAutomaticAppCreate make the mutation the file should be like the below image
`#graphql
mutation discountAutomaticAppCreate($automaticAppDiscount: DiscountAutomaticAppInput!) {
discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
userErrors {
field
message
}
automaticAppDiscount {
discountId
title
startsAt
endsAt
status
appDiscountType {
appKey
functionId
}
}
}
}`,
{
variables: {
automaticAppDiscount: {
title: discount_title,
functionId: "you function id goes here",
startsAt: enter a starting date it is compulsory
endsAt: null,
}
},
},
);
This is an accepted solution.
When you are done with coding of function you have to deploy the app on to your store. Once you have deployed it. In you .env file the app will create a function id of that Shopify Function and then you can use discountAutomaticAppCreate make the mutation the file should be like the below image
`#graphql
mutation discountAutomaticAppCreate($automaticAppDiscount: DiscountAutomaticAppInput!) {
discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
userErrors {
field
message
}
automaticAppDiscount {
discountId
title
startsAt
endsAt
status
appDiscountType {
appKey
functionId
}
}
}
}`,
{
variables: {
automaticAppDiscount: {
title: discount_title,
functionId: "you function id goes here",
startsAt: enter a starting date it is compulsory
endsAt: null,
}
},
},
);
Does the function id automatically be added on the .env file ? or I will manually add it based on the shopify partners dashboard ?
When You deploy the app after creating the discount function the app automatically creates a discount ID then you can use that by writing
process.env.SHOPIFY_CQ_PRODUCT_DISCOUNT_ID
Found it. Thank you so much.