Migrating from Shopify Scripts to Shopify Functions
Shopify Scripts was sunset on June 30, 2026. Any Scripts that were still published on your store have been deactivated and no longer function.
Shopify Scripts was sunset on June 30, 2026. Any Scripts that were still published on your store have been deactivated and no longer function.
- Stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions. Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.
- Some Shopify Functions capabilities are available only to stores on a Shopify Plus plan. See Shopify Function APIs for details.
- Stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions. Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.
- Some Shopify Functions capabilities are available only to stores on a Shopify Plus plan. See Shopify Function APIs for details.
This guide shows how to migrate your Shopify Scripts to Shopify Functions and validate the new Functions with tagged test customers before enabling them for everyone. Shopify Scripts allowed you to customize cart behavior, shipping, and payment methods in a store. With Shopify Functions, these customizations are now handled through dedicated Function APIs that offer better performance and flexibility.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Map your Shopify Scripts functionality to the right Shopify Functions.
- Verify new Functions with tagged test customers in production.
- Enable your verified Functions for all customers.
Anchor to RequirementsRequirements
- You have an existing Shopify Script that you want to migrate.
- You have access to a dev store for initial testing.
- You're familiar with creating Shopify Functions using Shopify CLI.
- You can open the Script Editor app in read-only mode to reference your original Script logic. The Script Editor is available until July 30, 2026.
Anchor to Function APIs mappingFunction APIs mapping
Use the following table to map your existing Shopify Script to the appropriate Function API:
| Shopify Script type | Shopify Function API | Use case |
|---|---|---|
| Line item scripts | Discounts API | Apply discounts to products, or the entire cart. |
| Line item scripts | Cart Transform API | Modify cart line items (bundle, merge, or add items). |
| Line item scripts | Cart and Checkout Validation API | Validate cart contents and block checkout under specific conditions. |
| Shipping scripts | Delivery Customization API and Discounts API | Hide, rename, or reorder delivery methods, and apply discounts to delivery methods. |
| Payment scripts | Payment Customization API | Hide, rename, or reorder payment methods. |
Anchor to Step 1: Add testing logic to your FunctionStep 1: Add testing logic to your Function
In your Shopify Function, add logic to target specific test users. The most reliable method is using customer tags.
Anchor to Tag test customersTag test customers
-
In the Shopify admin, go to Customers and add a tag like
TESTERto customers who should experience the new Function behavior. -
In your Function's input query, include customer tag information:
src/run.graphql
query Input {cart {buyerIdentity {customer {hasAnyTag(tags: ["TESTER"])}}# ... rest of your query}}
Anchor to Implement conditional logicImplement conditional logic
Add conditional logic in your Function to only apply new behavior to tagged customers:
File
Rust
// Check if the customer has the TESTER tag
let has_tester_tag = input
.cart()
.buyer_identity()
.and_then(|bi| bi.customer())
.map(|customer| customer.has_any_tag())
.unwrap_or(&false);
if *has_tester_tag {
// Apply new Function logic here
// ... your function implementation
} else {
// Untagged customers receive no operations during validation
return Ok(FunctionRunResult { operations: vec![] });
}JavaScript
const customer = input.cart.buyerIdentity?.customer;
const hasTesterTag = customer?.hasAnyTag ?? false;
if (hasTesterTag) {
// Apply new Function logic here
// ... your function implementation
} else {
// Untagged customers receive no operations during validation
return { operations: [] };
}Because Shopify Scripts no longer run, untagged customers receive none of this customization while the tag condition is in place. Keep the tagged validation period short, then remove the condition and enable the Function for all customers, as described in Step 3.
Anchor to Step 2: Deploy and test in productionStep 2: Deploy and test in production
You can test your Function in development and production.
Anchor to Development testingDevelopment testing
-
Test your Function thoroughly in a dev store:
Terminal
shopify app dev
Anchor to Production deployment and testingProduction deployment and testing
Choose one of the following deployment methods:
Anchor to Option A: App with configuration UIOption A: App with configuration UI
If your Function is part of an app with a user interface, then use the app to enable and configure the Function in production.
Anchor to Option B: GraphiQL deploymentOption B: Graphi QL deployment
This method works best for Functions that don't require ongoing merchant configuration.
This method works best for Functions that don't require ongoing merchant configuration.
If you have a custom Function without UI configuration, then complete the following steps:
-
Use the Shopify GraphiQL App to enable the Function directly.
-
Retrieve a list of available Functions using this query:
query.graphql
query getFunctions {shopifyFunctions(first: 100) {edges {node {idtitleapiType}}pageInfo {hasNextPageendCursor}}} -
Use the Function's
idin the appropriate creation mutation for your Function type (for example,discountAutomaticAppCreateordeliveryCustomizationCreate).
Anchor to Step 3: Complete the migrationStep 3: Complete the migration
After you've verified that the Function works correctly:
-
Remove testing code: Update your Function to remove the customer tag conditional logic.
-
Deploy the final version:
Terminal
shopify app deploy
Anchor to Best practicesBest practices
- Always test in a dev store before deploying to production.
- Keep the testing period short to minimize code complexity.
- Monitor your store's performance and error logs after migration.
- Document any differences in behavior between Scripts and Functions.
- Test edge cases that might behave differently between Scripts and Functions.
Anchor to TroubleshootingTroubleshooting
You might encounter the following issue during migration:
- Function not triggering: Verify the Function is properly enabled and configured.
- Different behavior: Check the input data structure your Function receives.