Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Is there a way to automatically install a shopify function into a store when an app is installed? I have an existing app that I'd like to replace the clunky buggy system we have now that updates product prices via AJAX and javascript with something that runs in the backend and Scripts are going to be deprecated soon.
Solved! Go to the solution
This is an accepted solution.
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.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
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.
To learn more visit the Shopify Help Center or the Community Blog.