⚠️   Shopify Scripts will no longer be supported as of June 30, 2026  ⚠️   read the Shopify article 

Practical Shopify Functions Examples for Plus Merchants

Table of Contents

  1. Introduction
  2. The Evolution: Why Functions Are Replacing Scripts
  3. Key Constraints and Platform Limits
  4. Delivery Customization Examples
  5. Payment Customization Examples
  6. Discount Logic Examples
  7. Checkout and Cart Validation Examples
  8. Choosing the Right Nextools Solution
  9. The Nextools Playbook: Implementation Workflow
  10. Advanced Use Cases: Beyond Basic Functions
  11. Summary Checklist for Success
  12. Nextools Shopify App Suite (Quick Links)
  13. FAQ

Introduction

Modern e-commerce requires more than just a “standard” checkout experience. For Shopify Plus merchants, the transition from the legacy Ruby-based Shopify Scripts to the new, high-performance Shopify Functions represents a significant shift in how business logic is executed. As the deadline for Script migration approaches, many technical teams face the pressure of replicating complex logic—such as tiered discounts, conditional shipping rates, or payment method restrictions—within a more rigid, yet scalable, architecture. At Nextools, we specialize in bridging this gap, providing tools and expertise to simplify the migration from Scripts to Functions and enabling merchants to customize their checkout without the overhead of building bespoke custom apps.

This post is designed for Shopify Plus merchants, development agencies, and in-house technical teams who need to understand the practical applications of this new technology. We will explore several real-world Shopify functions examples, detailing how they solve common checkout limitations and payment/shipping edge cases. By the end of this guide, you will have a clear blueprint for choosing and implementing the right logic for your store. Our approach follows the Nextools Playbook: clarify your goals and constraints, confirm platform limits, choose the simplest durable approach, implement safely in a staging environment, and measure the impact on your conversion and operational efficiency.

To explore our full range of solutions that leverage these technologies, visit the Nextools Shopify App Suite.

The Evolution: Why Functions Are Replacing Scripts

The shift toward Shopify Functions is driven by the need for performance and reliability. While Shopify Scripts were powerful, they ran on a Ruby-based sandbox that often struggled during massive flash sales or high-concurrency events. Functions, conversely, are built on WebAssembly (Wasm). This allows them to execute in under 5ms, ensuring that even the most complex logic doesn’t slow down the checkout process.

For developers and merchants, this means several things:

  • Performance: Functions scale effortlessly, making them ideal for “internet-breaking” sales.
  • Accessibility: Merchants can configure Functions directly in the Shopify Admin through an app interface, rather than editing code in the Script Editor.
  • Language Flexibility: While Shopify recommends Rust for its performance and safety, Functions can be written in any language that compiles to Wasm, including JavaScript.

At Nextools, we’ve developed SupaEasy specifically to help merchants navigate this transition. It acts as a bridge, allowing you to generate Functions via an intuitive interface or even use AI to assist in migrating old Ruby scripts.

Key Constraints and Platform Limits

Before diving into specific Shopify functions examples, it is critical to understand the environment in which they operate. Shopify Functions are not a “catch-all” for every customization. They are purposefully restricted to ensure checkout stability.

1. Shopify Plan Requirements

While any merchant can install a public app from the Shopify App Store that utilizes Functions, only Shopify Plus merchants have the “exclusive ability” to write and deploy custom Functions via custom apps for their specific store. This is a vital distinction for agencies working with non-Plus clients; for those merchants, a pre-built solution like our App Suite is often the only viable path.

2. Execution Environment

Functions run on Shopify’s infrastructure, not your server. This means:

  • Execution Time: You have a strict 5ms window. If your logic is too heavy, the function will fail, and the checkout will default to its original state.
  • Wasm Size: The compiled WebAssembly module must typically be under 256 KB.
  • No Network Access (Usually): Most Function APIs cannot make external API calls during execution. They must rely on the data provided in the GraphQL input query, though “Fetch” targets are being introduced for specific enterprise use cases.

3. The Sequence of Logic

Functions execute in a specific order. For example, product discount functions run before order discount functions. Understanding this sequence is essential for stores with complex “discount stacks.” If you are using Multiscount to manage tiered promotions, the app handles this sequencing logic for you, ensuring that discounts are applied in the correct, predictable order.

Delivery Customization Examples

The Delivery Customization API allows you to hide, sort, or rename shipping methods. This is particularly useful for merchants dealing with oversized items, international markets, or specific carrier restrictions.

Scenario: Hiding Express Shipping for Oversized Items

A common pain point for furniture or appliance retailers is the inability to offer expedited shipping for very heavy items. If a customer has a 100kg sofa in their cart, an “Express Air” option might be displayed by default, leading to either a massive shipping loss for the merchant or a failed fulfillment.

Using a Shopify Function, you can:

  1. Query Input: Pull the tags or metafields of all items in the cart.
  2. Evaluate Logic: If any item contains the tag “Oversized” or has a weight attribute above a certain threshold.
  3. Return Output: Instruct Shopify to hide the “Express Shipping” option for that specific checkout session.

This logic can be implemented easily with HideShip, which provides a no-code interface to create these rules without building a custom app.

Scenario: Renaming Rates Based on Delivery Date

If you use a local courier that only delivers on Tuesdays and Thursdays, you might want to rename “Standard Delivery” to “Local Delivery (Next Tuesday)” based on the current day of the week. While native Shopify settings are static, a Function can dynamically modify the string displayed to the customer, providing better clarity and reducing support tickets.

Payment Customization Examples

Similar to delivery, the Payment Customization API gives you control over which payment methods appear at checkout. This is often used for fraud prevention or to push customers toward lower-fee payment gateways.

Scenario: Hiding Cash on Delivery (COD) for High-Value Orders

In many markets (like Italy or India), COD is a popular but risky payment method. A merchant might want to disable COD if the order total exceeds $1,000 to minimize the risk of refusal upon delivery.

  • Constraint: You need to check the cart.totalAmount.
  • Action: If totalAmount > 1000, the Function hides the “Cash on Delivery” option.

For merchants using our HidePay app, this rule can be set up in seconds. You can even combine conditions, such as hiding certain payment methods only for specific countries or for customers with certain tags (e.g., “High Risk”).

Scenario: Sorting Payment Methods by Preference

If you want to encourage the use of a specific gateway (perhaps because of lower transaction fees or faster settlement), you can use a Function to reorder the list. You might place your preferred gateway at the top and push “Buy Now, Pay Later” (BNPL) options to the bottom to protect your margins on low-margin products.

Discount Logic Examples

The Discount APIs (Product, Order, and Shipping) are perhaps the most frequently used Shopify functions examples. They allow for logic that is far more granular than the standard “Automatic Discounts” in the Shopify Admin.

Scenario: Tiered “Spend More, Save More” Across Specific Collections

Standard Shopify discounts often struggle with “stacking” rules or applying different percentages based on different collection totals within a single cart.

  • Example: Spend $100 on “Accessories” get 10% off; spend $200 on “Apparel” get 20% off.
  • Function Solution: The Function iterates through the cart lines, aggregates the totals for each collection (defined via metafields), and calculates a custom discount amount that is returned to the checkout.

This level of complexity is why we built Multiscount. It allows merchants to create these tiered structures without needing to write Rust code, while still benefiting from the performance of the Functions API.

Scenario: BOGO (Buy One, Get One) with Custom “Companion” Logic

Sometimes, a gift shouldn’t just be “free.” It should be automatically added to the cart when a specific trigger product is present. Using a combination of a Function for the discount and AutoCart, you can create a seamless experience where the companion product is added and discounted 100% automatically.

Checkout and Cart Validation Examples

Validation Functions are a newer addition to the ecosystem, but they are incredibly powerful for enforcing business rules before an order is even placed.

Scenario: Restricting PO Box Deliveries for Specific Carriers

Certain carriers (like DHL or FedEx) cannot deliver to PO Boxes. If a merchant uses these carriers exclusively for international orders, they need to prevent the customer from completing the checkout if a PO Box address is detected.

  • Logic: The Function parses the shipping address lines.
  • Action: If a regex match for “PO Box” or “P.O. Box” is found and the shipping method is “DHL Express,” the Function returns an error message that is displayed directly in the checkout UI, blocking the “Pay Now” button.

Our Cart Block app is designed specifically for these scenarios, providing a robust way to validate addresses, quantities, and even specific email domains to prevent bot orders or fraud.

Choosing the Right Nextools Solution

With so many Shopify functions examples available, it can be difficult to decide whether to build a custom solution or use a specialized app. Use this decision checklist to guide your choice:

  1. Is the logic extremely niche? If you need to check an external proprietary database in real-time (not yet widely supported), you may need a custom app via SupaEasy Ultimate.
  2. Is the goal to hide/sort/rename? Use HidePay or HideShip. These are the most cost-effective and durable ways to handle payment and delivery logic.
  3. Is it about complex discounting? Multiscount is the standard for tiered and stackable logic.
  4. Do you need to block or validate? Cart Block handles the heavy lifting of checkout validation.
  5. Are you migrating from Shopify Scripts? SupaEasy is your primary tool for converting Ruby logic into Functions.

For a complete overview of how these tools work together, visit our Shopify App Suite hub.

The Nextools Playbook: Implementation Workflow

Regardless of the specific function you are implementing, we recommend following this structured engineering workflow:

Step 1: Clarify the Goal and Constraints

Start by documenting exactly what the function should do. Who is it for? (e.g., “Wholesale customers only”). What is the trigger? (e.g., “Cart total > $500”). Identify your Shopify plan and any conflicting apps.

Step 2: Confirm Platform Capabilities

Check the Shopify Function API documentation to ensure the data you need (like customer metafields or specific line item attributes) is available in the GraphQL input query. If it isn’t, you may need to find a workaround, such as using cart attributes via AttributePro.

Step 3: Choose the Simplest Durable Approach

Avoid building a custom app if a reliable third-party app exists. Custom apps require maintenance, hosting (even for the configuration UI), and constant API updates. Nextools apps are maintained by our specialist team, ensuring they stay compatible with the latest Shopify updates.

Step 4: Implement Safely

Never deploy a new Function directly to a live store.

  • Use a Development Store: Test the logic in a sandbox environment first.
  • QA Scenarios: Test the “happy path” (where the function works) and “edge cases” (e.g., an empty cart, a guest checkout, or an international address).
  • Rollback Plan: Know how to quickly disable the function if it causes unexpected checkout errors.

Step 5: Measure Impact and Iterate

After deployment, monitor your key metrics. Is the checkout completion rate steady? Are you seeing fewer support tickets regarding shipping or payment confusion? Use this data to refine your logic over time.

Advanced Use Cases: Beyond Basic Functions

As Shopify expands the scope of Functions, we are seeing more creative implementations that move beyond simple “hide/show” logic.

Order Routing and Fulfilment

For merchants with multiple warehouses, the Order Routing API (powered by Functions) allows you to define custom logic for which location should fulfill an order. You can prioritize warehouses based on proximity to the customer, current stock levels, or even the “cost to pick” for that specific order.

Custom Checkout Forms and Attributes

While not strictly a “backend logic” Function in the same way as discounts, Formify and AttributePro allow you to collect and process data that feeds into your Functions. For example, you might collect a “Preferred Delivery Date” via a custom form and then use a Delivery Function to hide shipping methods that cannot meet that date.

Localization and Translation

For global brands, the experience must be localized. CartLingo uses AI to ensure that the messages generated by your Functions—such as discount descriptions or validation errors—are translated accurately for every market.

Summary Checklist for Success

To ensure your implementation of Shopify Functions is successful, keep this checklist in mind:

  • Verify Plus Status: Ensure you are on Shopify Plus if you intend to deploy custom-coded Functions.
  • Identify Targets: Determine if your need falls under Discounts, Delivery, Payment, or Validation.
  • Audit Existing Scripts: If you are migrating, map each Ruby script to a corresponding Function API.
  • Optimize Performance: Keep your logic lean to stay within the 5ms execution limit.
  • Leverage Metafields: Use metafields to store the configuration data your Functions need.
  • Test Thoroughly: Use a staging environment to simulate various customer journeys.
  • Consult the Experts: If you are stuck, explore the tools available in the Nextools Shopify App Suite.

By focusing on durable, performant logic, you can transform your Shopify checkout into a strategic asset that drives conversion and simplifies operations.

Nextools Shopify App Suite (Quick Links)

FAQ

Do I need to be on Shopify Plus to use Shopify Functions?

To write and deploy your own custom Functions via a custom app, yes, you must be on a Shopify Plus plan. However, merchants on any Shopify plan (Basic, Shopify, Advanced) can install public apps from the Shopify App Store that use Functions logic, such as HidePay or Multiscount.

How do I test a Shopify Function before going live?

The best practice is to use a Shopify Development Store or a Plus Sandbox store. You can install the app containing the Function, configure your rules, and perform test checkouts using Shopify’s “bogus gateway” or test credit card numbers. This ensures your logic works without affecting real customers.

Can I migrate my old Shopify Scripts to Functions?

Yes, and you should, as Shopify is deprecating the Script Editor. While there isn’t a “one-click” converter for Ruby to Rust/Wasm, tools like SupaEasy provide a “Scripts Migrator” and AI-assisted generation to help you rebuild your logic within the new Functions framework.

Will using multiple Functions slow down my checkout?

No. Shopify Functions are designed for extreme performance. Each function has a strict 5ms execution limit and they run on Shopify’s global infrastructure. Because they are compiled to WebAssembly, they are significantly faster than the old Ruby scripts and will not negatively impact your conversion rate.

SupaEasy is a product built & designed by Nextools

Company

© [2024] website by Nextools. All Rights Reserved. PIVA: 16711981007