Migrate from Shopify Scripts to Shopify Functions
Shopify Functions are similar to Shopify Scripts, which let developers create custom commerce experiences.
On this page
Shopify Functions
Shopify Functions are installed as part of an app. They're configured alongside other features directly in your Shopify admin, which means that merchants don't need to use code when they're creating or modifying customizations. The WebAssembly platform that runs Shopify Functions offers better performance than Shopify Scripts, executing code in under 5 milliseconds. Because of this, Shopify Functions can support large sales events such as flash sales with no decrease in performance.
By using Shopify Functions, developers can code and unit test in their own local environment. Developers distribute their Shopify Functions customizations as part of an app, rather than copying and pasting Ruby code into each store. Finally, timeout and CPU memory limit issues are reduced by using Shopify Functions.
Migrate to Shopify Functions
It's recommended to start migrating to Shopify Functions with delivery or payment customization Shopify Functions-based apps, and using them along with line-item discount scripts. When you're comfortable using delivery and payment Shopify Functions, you can then progress to using discount Shopify Functions.
Steps:
- From your Shopify admin, go to Apps > Script Editor.
- Review your existing scripts. Refer to the discount, delivery, and payment comparison tables to determine which of your scripts can be replicated by using Shopify Functions.
- If a script can't be replaced by using Shopify Functions, then continue using the script until the Shopify Functions APIs meet your needs.
- If a script can be replaced by using Shopify Functions, then do one of the following:
- Refer to the Shopify App Store to determine if a publicly-available app meets your needs.
- If your store is on the Shopify Plus plan, then you can create your own Shopify Functions-based custom app. Tutorials are available for creating discount, payment customization, and delivery customization apps.
- After identifying a Shopify Functions-based app that meets your needs, install the app on your store, and then configure the app's settings in the Shopify admin.
- Test the app to verify that it acts as intended. If the app fulfills your requirements, then deactivate the Script that the Shopify Functions-based app is replacing.
Using Shopify Scripts with Shopify Functions
Shopify Scripts will continue to work on checkouts that are customized with checkout.liquid and on checkouts that have been upgraded to checkout extensibility until August 28, 2025.
Shopify Scripts and Shopify Functions can be used at the same time in a single store. If your scripts can't currently be replaced by using Shopify Functions, then continue to use Shopify Scripts until the Shopify Functions APIs meet your needs. Refer to the following to determine how Shopify Scripts and Shopify Functions interact.
Line item scripts
Line item scripts execute before Shopify Functions, which includes discounts that are created by apps. Line item scripts cannot access the amounts that have been discounted by functions & apps.
Scripts can access only the first discount code applied to the checkout, and can't access into other discount codes that might have been used. For example, using reject
operates on the first discount applied to the checkout, and does not affect other discounts.
Shipping scripts
Shipping scripts execute after delivery customizations that are created by Shopify Functions. Scripts can't operate on modified delivery customization rename results, but can operate on customizations that move or hide.
Payment scripts
Payment scripts execute after payment customizations that are created by Shopify Functions. Scripts can't operate on modified payment customization rename results, but can operate on customizations that move or hide.