Skip to content
Roman-Leonid Yurchenko

Shopify Functions Developer

Business rules that hold at checkout

A Shopify Function is code that runs inside Shopify’s own pricing and checkout path rather than alongside it. That single property is the reason to use one: a theme can display whatever it likes, but the Function is what Shopify actually charges.

Application

What it is for

The problems that actually justify reaching for this, rather than the ones a feature list would claim.

  1. 01Discounts that depend on cart composition, customer segment or metafield state rather than on a code the customer types.
  2. 02Pricing a set of products as a unit when the whole combination is present.
  3. 03Hiding, renaming or reordering delivery and payment options by rule.
  4. 04Blocking a checkout that violates a business constraint, where client-side validation is not enough.
  5. 05Replacing a paid app whose entire job is one rule the platform can now enforce natively.

Boundary

Where the boundary is

Does this person know where Functions stop working?

6 limits · no records required

Placeholder copy

A Function sees only what its input query asked for. The input is a GraphQL query you declare up front, and there is no second lookup at runtime.
The data model gets decided before the logic does. Discovering halfway through that you need one more field is a change to the query, the deployment and the tests — not a line of code.
No network access. A Function cannot fetch a price, look up stock in another system, or call an API.
Anything the rule depends on has to be in the input or in metafields before checkout begins. If the source of truth lives outside Shopify, the real design problem is getting it in, and the Function is the easy part.
There is an instruction budget, and exceeding it is a hard failure rather than a slow response.
The number to test against is the largest realistic cart, not the average one. Cost scales with cart size, so a Function that is comfortable in development can fail on the wholesale order that matters most.
Discount Functions cannot create cart lines. Cart Transform can merge lines or expand one into components; neither invents a line that was not already there.
"Add a free gift" and "price this bundle as a unit" are different problems with different answers, and which one you have been asked for is worth settling before any code is written.
Whether a Function combines with other discounts is a configuration decision, not an implementation detail.
It is the first thing a merchant asks about after launch. Deciding it deliberately is cheaper than discovering it from a support ticket.
A rule a merchant will want to change does not belong in the code.
Thresholds, tiers and product sets go in metafields with an admin surface. Hardcoding them turns every business decision into a developer deployment, which is the situation the Function was meant to end.

Placement

When I reach for something else

Most Shopify decisions are placement decisions. Naming what this is not for is the same judgement as knowing what it is for.

Placeholder copy

Theme
The rule is presentation. The cart a theme renders is not the cart Shopify prices, so a rule enforced there stays reachable through a stale page or a direct cart POST.
Checkout UI Extension
The customer has to see or enter something. A Function has no interface — pair the two rather than choosing between them.
Admin configuration
Shopify already does it. Native discounts, markets and B2B catalogs cover more than they are given credit for, and none of them need maintaining.
App
The state is not Shopify’s. An app accepts sync risk in exchange for owning data the platform does not model, which is a real trade and sometimes the right one.

Evidence

Code you can read

3 published

Shopify FunctionTypeScript

Preserving tiered set prices with Cart Transform

A merchant needs configurable greenhouse kits to use prices managed as catalog tiers while preserving each selected module as an order component that carries inventory.

Known limits

Carrier variant
Every price tier needs a real carrier variant; the Function cannot create or select that cart line.
Allocation
Equal component allocation misstates line value when selected items have different economic weights.
Selling plans
Selling plan lines cannot be expanded, so this contract cannot price subscription kits.
Stale IDs
Stale component IDs are detected only when Shopify applies the expansion.
Currency
The money model supports only presentment currencies with two decimal places.
Complex commercePlus platformCatalog architecture
Shopify FunctionTypeScript

Validating nested bundle integrity

A merchant needs configurable field monitoring kits to reach checkout only when every nested sensor module is authorized, correctly positioned, and attached to the real carrier.

Known limits

Repair
The Validation Function can block an invalid kit but cannot remove, repair, or change the parent relationships of its lines.
Error detail
Multiple invalid kits produce one generic cart error instead of repair instructions for each instance.
Nesting depth
The contract relies on parent relationships limited to one level and cannot represent modules nested beneath other modules.
Catalog IDs
Carrier policies authorize current variant IDs, so catalog replacements require policy migration before old IDs are retired.
Complex commercePlus platform
Shopify FunctionTypeScript

Gift qualification using cart relationships

A specialty coffee merchant needs one sample bag to become free only when a paid product at the top level qualifies, without bundle children creating or receiving manual entitlement.

Known limits

Gift insertion
The Discount Function cannot add a missing gift line; the shopper or storefront must put an eligible sample in the cart.
Shopper intent
When several samples qualify, the Function discounts the cheapest one rather than preserving shopper intent.
Nested lines
Nested merchandise can neither qualify nor receive the manual gift discount.
Product lists
The lists of allowed qualifier and gift products are capped at 50 product IDs each.
Combinations
Discount combinations remain an administrative policy outside this evaluator.
Complex commercePlus platform

Next step

Best fit for established Shopify teams and agencies with requirements beyond routine theme edits.