Hi there ![]()
Is there a way to automatically install a shopify function into a store when an app is installed?
To add a Shopify Function on a store you will need to create a discount object that references your function. You create the discount object with an GraphQL mutation. In your install flow you can make the API call to create the discount object that references your function to activate the function on your store.
I would recommend working through this tutorial. In the tutorial they make the API call with GraphiQL to activate the function, but this can be modified to take place in the installation flow of the app.
It is important to note that to use Shopify Functions with an existing app, your app need to be compatible with the Shopify CLI.