Shopify Functions: Custom Backend Logic Without Apps
For years, if you needed custom business logic on Shopify, you had two bad options. Option one: install an app (which adds bloat, slows checkout, and takes a percentage of revenue). Option two: hire a developer to build a custom app (which costs $10K+ and requires ongoing maintenance).
Shopify Functions changed the game. They let you write code—actual JavaScript or Wasm—that runs on Shopify's servers and intercepts orders, pricing, and fulfillment decisions. No UI, no bloat, no revenue share. Just pure backend logic.
The merchants using Shopify Functions aggressively are seeing remarkable things: 15-25% better AOV through smart dynamic pricing, zero-lag checkout experiences because custom logic runs server-side (not in JavaScript), and complete independence from app ecosystem dependencies.
Here's what you need to know to get started.
What Are Shopify Functions, and Why Do They Matter?
Shopify Functions is a platform that lets you write backend code that runs at critical Shopify system points. These "hooks" are:
| Hook Type | What It Controls | Typical Use Case |
|---|---|---|
| Discounts | Dynamic discounts, BOGO rules, volume pricing | Custom pricing logic, volume tiers |
| Shipping | Custom shipping methods, rate adjustments, carrier logic | Region-specific rates, subscription discounts |
| Payments | Payment method availability, conditional payment methods | Hide payments by cart value, region, product type |
| Fulfillment | Fulfillment logic, carrier assignment, warehouse routing | Smart routing, zone-based fulfillment |
| Cart & Checkout | Custom line items, note injection, cart transformation | Add fees dynamically, bundle logic |
The key insight: Functions run on Shopify's infrastructure, not your storefront. That means zero JavaScript bloat, sub-10ms latency, and guaranteed uptime. It's the opposite of how most Shopify customizations work (loading custom apps in the checkout).
A mid-market D2C brand implemented custom shipping logic via Functions and saw checkout abandonment drop 8% just because the shipping method calculation was instant (previously an app was adding 400ms lag). That's pure speed and user experience improvement.
The Architecture: How Shopify Functions Work
Here's the execution model:
- You write code in JavaScript (TypeScript) or WebAssembly
- You deploy to Shopify's function registry (via CLI)
- At runtime, when an order is placed, payment selected, or shipping calculated, Shopify executes your function
- Your function returns a mutation (new price, new shipping method, etc.)
- Shopify applies that mutation to the order/checkout
The code is stateless and deterministic. It receives an input (order, customer, product details) and returns a transformation. No database calls, no side effects, no webhooks.
The sandboxed execution model is intentional. Shopify limits what Functions can do (no HTTP requests, no file I/O) to guarantee performance and security. But that's fine—most business logic doesn't need external calls.
Here's a simplified example (not real code, but illustrative):
Function Input:
{
"cart": {
"lines": [{"product_id": "123", "quantity": 2}],
"subtotal": 150
},
"customer": {"tags": ["vip", "loyalty"]}
}
Your Function Logic:
if (customer.tags.includes("vip") AND cart.subtotal > 100) {
apply_discount(15%)
}
Function Output:
{
"discounts": [{"percentage": 15}]
}
Shopify receives your output and immediately applies it to the checkout. No roundtrips, no network latency.
Real Use Cases (and What They've Saved Merchants)
Case 1: Dynamic Volume Pricing
A home goods brand needed volume-based pricing (5+ units = 10% off, 10+ = 20%, 15+ = 30%). Apps offering this charge 2-5% of revenue. The brand used Shopify Functions to write the logic themselves (30 lines of code) and saved $40K+ annually.
The Function evaluates cart quantity in real-time and applies the discount. The checkout is instant because there's no external service doing the math.
Case 2: Smart Shipping Rules
A furniture company ships to 45 states. Regional shipping costs vary wildly (West Coast = $95, Midwest = $45, East Coast = $65). They built a Function that:
- Reads the zip code
- Maps it to a region
- Returns region-specific carrier rates
Previously, they used an app that added 800ms to checkout. The Function adds <10ms. Result: checkout time dropped from 6.2 seconds to 3.8 seconds. Conversion rate improved 2.3%.
Case 3: Payment Method Gating
A high-AOV luxury brand wants to hide credit cards for orders under $100 (to force payment plan usage) and hide payment plans for orders over $10K (to push invoicing). A Function reads the cart subtotal and returns:
if (subtotal < 100) return {hidden_methods: ["credit_card"]}
if (subtotal > 10000) return {hidden_methods: ["payment_plan"]}
This is simple but impossible to do with apps (which can't conditionally hide payment methods). Functions make it trivial.
Execution Challenges: What to Expect
Shopify Functions are powerful, but there are constraints:
| Constraint | Impact | Workaround |
|---|---|---|
| No HTTP requests | Can't call external APIs within the function | Pre-fetch data via webhooks or daily syncs |
| No database access | Can't look up order history in custom tables | Use Shopify's built-in customer/order API (limited scope) |
| 50ms execution limit | Function must complete quickly | Optimize algorithm, cache data locally |
| Stateless execution | No memory between invocations | Store state in Shopify objects or customer metafields |
The constraint that trips most merchants: "No external API calls." You can't call a third-party pricing API from within a Function. However, you can pre-populate your function with data (pricing tables, rules, configuration) that's compiled at deployment time.
For example: A brand wanted to use an inventory system to calculate shipping (if item in stock at warehouse A, use carrier X). The solution: sync inventory to Shopify's inventory API daily, then have the Function read from Shopify (which is allowed). Not real-time, but good enough.
Getting Started: The Developer Path
Shopify Functions require developer knowledge. Here's the skill stack:
- JavaScript/TypeScript: Functions are written in JS or Rust/Wasm
- Shopify CLI: Command-line tool for deploying functions
- Git/version control: Functions are code—treat them like it
- Testing: Unit test your logic before deploying (especially for pricing/shipping)
The setup:
npm install @shopify/cli --global
shopify app create --template custom-app
cd your-app
shopify app function create --template discounts
The Shopify CLI scaffolds a basic function. You write your logic and deploy:
shopify app deploy
The new function is live in your store's admin. No app installation, no customer friction.
One critical detail: Functions must be deployed as part of a custom app. A custom app is your app (not in the Shopify App Store). You create it once and never think about it again. It's not user-facing—it's just a container for your function code.
Real Performance Impact: Numbers from Live Stores
Here's what merchants have reported after implementing Shopify Functions:
| Metric | Pre-Function | Post-Function | Improvement |
|---|---|---|---|
| Checkout latency | 400-800ms | 10-50ms | 10-80x faster |
| Checkout abandonment | 72% | 64% | 8% absolute reduction |
| AOV (with custom pricing) | $150 | $175 | 16% increase |
| Revenue from subscriptions (via gating) | $0 | $45K/year | New revenue stream |
| App fees (eliminated) | 2-5% of revenue | $0 | $20K-$100K+ savings |
The checkout latency improvement is profound. Most Shopify apps add 300-1000ms of latency to checkout (they're JavaScript, they load remotely, they wait for external APIs). Functions add <50ms because they're server-side.
One mid-market brand reduced checkout time from 7.2 seconds to 3.8 seconds by replacing three apps with one custom function. Conversion rate lifted 4.2%. That's not a coincidence.
When NOT to Use Shopify Functions
Functions are powerful, but they're not for everything:
- UI-heavy customization: Functions have no UI. If you need a custom checkout widget or admin interface, use a custom app instead.
- Webhook-based logic: If you need to trigger actions outside Shopify (email a team, update an external database), use webhooks, not functions.
- Machine learning models: If you're running predictions (ML-based personalization, fraud detection), Functions aren't the right tool (too compute-limited).
For these cases, use custom apps + webhooks.
The Competitive Advantage
The merchants winning with Shopify Functions aren't using them for vanity features. They're using them to:
- Eliminate app bloat (every app slows checkout)
- Gain control over core business logic (pricing, fulfillment)
- Reduce costs (no revenue share with app vendors)
- Own their data and logic (not dependent on external services)
The unstated advantage: agility. When your logic lives as code on Shopify's servers, you can iterate fast. Need to change a shipping rule? Deploy a new function in 2 minutes. Need to adjust pricing tiers? Change one line and deploy. No app store approval, no waiting for vendor updates.
Ready to Build Custom Logic on Shopify?
Shopify Functions are the most powerful customization tool available on the platform right now. If you're running on Shopify Plus or want to eliminate app bloat and own your business logic, this is the path forward.
The barrier is technical—you need a developer who understands JavaScript and Shopify's API. If you need help designing the right function architecture for your store, reach out to Tenten.
Editorial Note
Shopify Functions represent a shift back to first principles: write code that does exactly what you need, deploy it, and get out of the way. Apps will still have a place for specific, vertical use cases. But core logic (pricing, shipping, payment gating) belongs on Functions.
Frequently Asked Questions
Do I need a custom app to deploy Shopify Functions?
Yes. Functions are deployed as part of a custom app (created in your store's admin under "Apps and Sales Channels"). This is free—you're not paying anything to Shopify. The custom app is just a container for your function code.
Can I use Shopify Functions on a standard Shopify plan?
Yes. Some functions (like Discounts) are available on all plans. Others (Fulfillment, advanced Shipping) require Shopify Plus. Check Shopify's documentation for your plan tier.
How do I test my function before deploying to production?
Use Shopify's testing sandbox and CLI. Write unit tests for your function logic (especially pricing/discounts). Test in development first, then deploy.
What programming language do Shopify Functions use?
JavaScript/TypeScript or Rust/WebAssembly. JavaScript is simpler for most merchants; Wasm is faster but requires more expertise.
Can I call an external API from a Shopify Function?
No. Functions can't make HTTP requests. However, you can pre-populate your function with data (via configuration files) and sync external data to Shopify periodically using webhooks.