November 5, 2026 · 7 min read

Which Shopify Function API Replaces Your Script: Discounts, Delivery, or Payment Customization

Shopify Scripts stopped running on June 30, 2026. Here is the definitive map of which Function API replaces each script type, with limits, plan

Which Shopify Function API Replaces Your Script: Discounts, Delivery, or Payment Customization

If your Script ran discount logic, it belongs in the Discount Function API. If it hid or reordered shipping rates, that is Delivery Customization. If it filtered payment methods, that is Payment Customization. Those are the three Function APIs that absorbed the entire Shopify Scripts surface area, and each one has a distinct execution phase, plan requirement, and hard limit that you need to understand before you deploy anything.

Shopify Scripts stopped executing on June 30, 2026. The Script Editor locked for edits even earlier, on April 15, 2026, so any store still relying on Scripts after that date was running frozen, unmodifiable code until the final shutdown.

Key takeaways

  • Shopify Scripts were fully retired on June 30, 2026; the Discount, Delivery Customization, and Payment Customization Function APIs are the direct replacements.
  • In API version 2025-04 (shipped May 21, 2025), Shopify collapsed the separate Product, Order, and Shipping Discount APIs into one unified Discount Function API.
  • Custom Functions (your own app, one store) require Shopify Plus. Public App Store apps that contain Functions install on any plan.
  • Each of the three Function APIs allows up to 25 active functions per store.
  • Functions are compiled WebAssembly modules with a hard 5 ms execution cap and a 256 KB bytecode size limit per function.

Why the mapping matters before you write a line of code

The mistake I see most often after a Script migration is a developer who reads the word "discount" in their old Script and immediately reaches for the Discount Function API, even when the Script was actually hiding a shipping rate based on cart weight. That is the wrong API. The result is a function that compiles, deploys, and does absolutely nothing at checkout, with no error to show for it.

The correct mental model, as described in Shopify's Functions documentation, is:

  • Cart Transform answers "what does the cart contain?" (bundles, expanding line items)
  • Discount answers "what price adjustments apply?"
  • Delivery Customization answers "which shipping options are shown?"
  • Payment Customization answers "which payment methods are shown?"

Shopify runs them in that order. A Cart Transform that assembles a bundle has already executed by the time your Discount Function sees the cart. Discount results are finalized before Delivery and Payment Customization run.

The full Script-to-Function mapping

Old Shopify Script typeFunction API replacementWhat it can doPlus required?
Line item Script (price/discount)Discount Function APIProduct discounts, order subtotal discounts, shipping discountsCustom app: Plus. Public app: any plan
Shipping Script (rate visibility)Delivery CustomizationHide, rename, reorder shipping ratesCustom app: Plus. Public app: any plan
Shipping Script (rate pricing)Discount Function API (shipping class)Reduce or zero out a shipping rate costCustom app: Plus. Public app: any plan
Payment ScriptPayment CustomizationHide, rename, reorder payment methodsCustom app: Plus. Public app: any plan

Note that a shipping Script doing two jobs (hiding a rate AND discounting it) now needs two separate Function APIs. That is the one case where the migration is not a straight one-to-one replacement.

Discount Function API: what changed in 2025-04

Before May 21, 2025, there were three separate Function APIs: Product Discount, Order Discount, and Shipping Discount. All three carried deprecation notices after Shopify shipped the unified Discount Function API in version 2025-04. If you have Functions still targeting the old individual APIs, the migration guide sets api_version = "2025-04" as the floor in shopify.extension.toml.

The new API folds everything into two targets:

  • cart.lines.discounts.generate.run for product and order-level discounts
  • cart.delivery-options.discounts.generate.run for shipping discounts

One function can now discount products, the order subtotal, and shipping in a single pass. The return shape changed too: instead of a discounts array paired with a discountApplicationStrategy, the function returns an operations array.

A minimal JavaScript Discount Function for "10% off orders over $100" looks like this:

// shopify.extension.toml: api_version = "2025-04"
export function run(input) {
  const subtotal = input.cart.cost.subtotalAmount.amount;
  if (parseFloat(subtotal) < 100) return { operations: [] };
  return {
    operations: [
      {
        cartLinesDiscountsApply: {
          targets: input.cart.lines.map(l => ({ cartLineId: l.id })),
          value: { percentage: { value: "10.0" } },
        },
      },
    ],
  };
}

One gotcha that will burn you in a catalog with complex pricing tables stored in metafields: if a metafield value exceeds 10,000 bytes, the Function input returns null for that field, not an error. Every local test passes, production silently reads nothing.

Hard limits on Discount Functions

  • Maximum 25 active Discount Functions per store
  • 256 KB Wasm bytecode per function
  • 5 ms hard execution cap (function is aborted and operations ignored if exceeded)
  • GraphQL input query: maximum 3,000 bytes, calculated cost no more than 30, list-type field arguments capped at 100 elements

Delivery Customization: the shipping Script replacement

Delivery Customization runs at the rate-shopping step, after Shopify fetches available carrier rates but before the buyer sees them. The operations it supports are hide, move (reorder), and rename.

A Rust snippet that hides free delivery for addresses outside a target country:

#[shopify_function]
fn cart_delivery_options_transform_run(
    input: schema::cart_delivery_options_transform_run::Input,
) -> Result<schema::CartDeliveryOptionsTransformRunResult> {
    let country = input
        .cart
        .delivery_groups
        .first()
        .and_then(|g| g.delivery_address.as_ref())
        .and_then(|a| a.country_code.as_ref())
        .map(|c| c.as_str())
        .unwrap_or("");

    if country == "US" {
        return Ok(schema::CartDeliveryOptionsTransformRunResult { operations: vec![] });
    }
    // find and hide the free delivery option handle
    // ...
}

This pattern comes up constantly on stores with 10,000+ SKUs where some products are oversized and ineligible for certain carriers. The function receives the full delivery group context including weight, so the logic is straightforward; the trap is that you are working on delivery groups, not individual cart lines, so the loop structure is different from a Discount Function.

Key Delivery Customization facts

  • Maximum 25 active Delivery Customization Functions per store
  • Does not apply in POS (functions run but operations are ignored)
  • Configuration for which country or tag triggers the rule is best stored in a metafield so merchants can change it without a redeploy (see the Functions + metafields pattern)
  • Delivery options include shipping carriers, local delivery, and pickup options. All three are addressable by the same API

Payment Customization: the payment Script replacement

Payment Customization runs at checkout render, Phase 6 of the checkout pipeline, after all discounts and delivery costs are finalized. Operations are hide, move, and rename, plus two B2B-specific ones: set payment terms and add a review requirement (which submits the order as a draft).

export function run(input) {
  const total = parseFloat(input.cart.cost.totalAmount.amount);
  const hideOps = input.paymentMethods
    .filter(pm => /cash on delivery|cod/i.test(pm.name) && total > 500)
    .map(pm => ({ paymentMethodHide: { paymentMethodId: pm.id } }));
  return { operations: hideOps };
}

Two important caveats from the official API docs:

  • Payment Customization Functions do not apply operations in POS at all.
  • In Shop Pay, Payment Customization Functions only apply operations on the native gift card field. All other payment methods are outside the function's reach in that surface.

For B2B, the payment terms API lets you set a deposit percentage (1-99%) and a due-in-days value from the allowed set: 7, 15, 30, 45, 60, or 90 days.

Payment Customization limits

  • Maximum 25 active Payment Customization Functions per store
  • Some operations are Plus-only (review requirements and payment terms)
  • Functions with network access (calling an external API from inside the function) require Plus and Shopify approval

Plan requirements, side by side

PathDiscountDelivery CustomizationPayment Customization
Public App Store appAny planAny planAny plan
Custom app (your code, one store)PlusPlusPlus
Plus-only operations (terms, review)N/AN/APlus
Network access inside functionPlus + approvalPlus + approvalPlus + approval

The plan picture is the detail most migration guides gloss over. Scripts were Plus-only by definition, so every store running a Script already had Plus. After migration, a merchant who downgrades from Plus loses the custom app, not the installed public app. That is worth documenting in your handoff notes.

How to verify your functions are actually running

The Shopify admin's Scripts customizations report (under Settings) maps Scripts that were active before June 30, 2026 to their Function-API counterparts and links to relevant apps. Use it as a checklist, not as proof that migration is complete.

To confirm a Function fired:

  1. Open the Shopify admin, navigate to Discounts (or Delivery customizations / Payment customizations depending on API type).
  2. The active Function appears as an entry there with a status indicator.
  3. Place a test order through the standard checkout, then through Shop Pay, then through a draft order. Each surface behaves differently.
  4. For Delivery and Payment Customization, also test POS if that channel is active, since both APIs currently skip operations in POS.
  5. For Discount Functions, check that the discountAllocations on the order match expectations via the Admin GraphQL API (order.discountAllocations { allocatedAmountSet { shopMoney { amount } } discountApplication { ... } }).

No Function event appears in the standard Shopify logs, so the only reliable verification is order-level data inspection and integration testing against a development store.

Picking JavaScript vs. Rust

Both are officially supported. Rust compiles to tighter bytecode and delivers roughly 3-5x better cold-start latency, but for simple discount and delivery logic the difference is barely perceptible within the 5 ms wall. JavaScript via the Javy toolchain is sufficient for the majority of real-world Functions. Reach for Rust when you have deeply nested tier calculations or large metafield-driven lookup tables where instruction count starts to matter.

The shipping Script that needed two Functions

The one mapping that always causes a second conversation: a shipping Script that both hid certain rates and discounted others now requires a Delivery Customization Function (for hiding/reordering) and a Discount Function targeting the shipping class (for reducing the rate price). They run in separate pipeline phases and cannot be merged into one API call. Scope that correctly upfront; it is typically a medium-effort migration rather than an easy one.

If you would rather hand this off, my studio Lintel offers Shopify Functions development.

shopify functionsshopify scriptsdiscount functiondelivery customizationpayment customization

Frequently asked questions

Which Shopify Function API replaces line item Scripts?

Line item Scripts are replaced by the Discount Function API, which handles product discounts, order subtotal discounts, and shipping discounts in a single unified API since version 2025-04. Custom Discount Functions require Shopify Plus; public App Store apps that contain the Function run on any plan.

Do I need Shopify Plus to use Shopify Functions?

Only for custom apps that contain Functions and for certain Plus-only operations like payment terms and review requirements. Public App Store apps that wrap Functions install on any Shopify plan, which is a meaningful change from Scripts, which were Plus-only across the board.

Do Payment Customization Functions work in Shop Pay and POS?

Not fully. In POS, Payment Customization Functions run but their operations are not applied. In Shop Pay, the function only applies operations on the native gift card field; all other payment methods are outside the function's reach in that surface.

Seven years of Shopify, on one page.

Roles, projects, stack and certifications are on the resume.

Resume Download PDF LinkedIn