Skip to content
Skills Library
Programming · Building & coding

shopify-functions

/shopify-functions

Build Shopify Functions for custom discount, payment, and delivery logic in a WASM sandbox. Use when creating custom discount rules, payment customizations, delivery options, or cart transformations that run server-side at checkout. Trigger with phrases like "shopify functions", "shopify discounts", "shopify wasm", "custom discount function", "shopify checkout customization".

Licence
MIT
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
0
HTML comments
0
URLs in SKILL.md
4
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Build Shopify Functions for custom discount, payment, and delivery logic in a WASM sandbox. Use when creating custom discount rules, payment customizations, delivery options, or cart transformations that run server-side at checkout. Trigger with phrases like "shopify functions", "shopify discounts", "shopify wasm", "custom discount function", "shopify checkout customization".

Triggers from the description

shopify functionsshopify discountsshopify wasmcustom discount functionshopify checkout customization
Original author description

Build Shopify Functions for custom discount, payment, and delivery logic in a WASM sandbox. Use when creating custom discount rules, payment customizations, delivery options, or cart transformations that run server-side at checkout. Trigger with phrases like "shopify functions", "shopify discounts", "shopify wasm", "custom discount function", "shopify checkout customization".

How it works

  1. Overview
  2. Prerequisites
  3. Instructions
  4. Output
  5. Error Handling
  6. Examples
  7. Resources
Original SKILL.md headings · 130 lines, 528 words
SKILL.md preview
---
name: shopify-functions
description: 'Build Shopify Functions for custom discount, payment, and delivery logic
  in a WASM sandbox.

  Use when creating custom discount rules, payment customizations, delivery options,

  or cart transformations that run server-side at checkout.

  Trigger with phrases like "shopify functions", "shopify discounts",

  "shopify wasm", "custom discount function", "shopify checkout customization".

  '
allowed-tools: Read, Write, Edit, Bash(npm:*), Grep
version: 2.7.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
- saas
- ecommerce
- shopify
compatibility: Designed for Claude Code
---
# Shopify Functions

## Overview

Shopify Functions execute custom business logic in a WebAssembly sandbox at checkout: discounts, payment filtering, delivery customization, and cart transforms. They run server-side with strict constraints (11ms execution, 1MB memory, no network access) and replace Shopify Scripts.

## Prerequisites

- Shopify CLI 3.x+ installed (`npm install -g @shopify/cli`)
- Shopify Partners account with a development store
- App configured for the target function API type

## Instructions

### Step 1: Configure the Function Extension

```toml
# extensions/product-discount/shopify.extension.toml
api_version = "2025-01"
type = "product_discounts"

[[targeting]]
target = "purchase.product-discount.run"
input_query = "extensions/product-discount/input.graphql"
export = "run"
```

### Step 2: Define the Input Query

The input query declares what data your function receives at runtime:

```graphql
# extensions/product-discount/input.graphql
query Input {
  cart {
    lines {
      quantity
      merchandise {
        ... on ProductVariant {
          id
          product { hasAnyTag(tags: ["VIP-DISCOUNT"]) }
        }
      }
    }
  }
  discountNode {
    metafield(namespace: "$app:discount-config", key: "percentage") { value }
  }
}
```

### Step 3: Implement the Function

```typescript
// extensions/product-discount/src/run.ts
import type { Input, FunctionRunResult } from "../generated/api";

export function run(input: Input): FunctionRunResult {
  const percentage = parseFloat(input.discountNode?.metafield?.value ?? "0");
  if (percentage === 0) return { discounts: [], discountApplicationStrategy: "FIRST" };

  const targets = input.cart.lines
    .filter((line) => line.merchandise.product.hasAnyTag)
    .map((line) => ({ productVariant: { id: line.merchandise.id } }));

  return {
    discounts: [{
      targets,
      value: { percentage: { value: percentage.toString() } },
      message: `${percentage}% VIP Discount`,
    }],
    discountApplicationStrategy: "FIRST",
  };
}
```

### Step 4: Test and Deploy

```bash
shopify app function typegen          # Generate types from input query
shopify app function build            # Build to WASM
shopify app function run --input test-input.json  # Test locally
shopify app deploy                    # Deploy with app
```

See [function-types.md](references/function-types.md) for all function types, [input-output-schemas.md](references/input-output-schemas.md) for I/O shapes, and [wasm-constraints.md](references/wasm-constraints.md) for sandbox limitations.

## Output

- WASM binary deployed as a Shopify Function extension
- Custom discount/payment/delivery logic running server-side at checkout
- Type-safe input/output via generated TypeScript types
- Configurable via metafields (merchant-editable without code changes)

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| `FunctionError` | Runtime panic or unhandled exception in WASM | Add error handling; check optional fields for null |
| `FUNCTION_TOO_LARGE` | WASM binary exceeds 256KB | Tree-shake deps; use Rust for smaller binaries |
| Input query validation | Query references unavailable fields | Match `api_version` to available schema fields |
| Timeout (>11ms) | Function exceeds execution limit | Reduce iterations; pre-compute in metafields |

## Examples

### Creating a VIP Discount Function

Build a product discount function that applies a configurable percentage off for items tagged "VIP-DISCOUNT" using metafield-driven configuration.

See [Function Types](references/function-types.md) for all available function types and their targeting.

### Defining Input Queries and Output Schemas

Design the GraphQL input query that declares what cart data your function receives, and return the correctly shaped `FunctionRunResult`.

See [Input/Output Schemas](references/input-output-schemas.md) for I/O shapes per function type.

### Working Within WASM Sandbox Limits

Your function hits the 11ms execution timeout or 256KB binary size limit. Apply optimization strategies for the constrained WASM environment.

See [WASM Constraints](references/wasm-constraints.md) for sandbox limitations and workarounds.

## Resources

- [Shopify Functions Overview](https://shopify.dev/docs/apps/build/functions)
- [Product Discount Tutorial](https://shopify.dev/docs/apps/build/discounts/build-discount-function)
- [Function APIs Reference](https://shopify.dev/docs/api/functions)
- [WASM Limitations](https://shopify.dev/docs/apps/build/functions/input-output#limitations)
Files in this package (4)
  • SKILL.md 5 KB
  • references/function-types.md 3 KB
  • references/input-output-schemas.md 4 KB
  • references/wasm-constraints.md 3 KB

Versions

RepositoryScoreLicence
This page · jeremylongshore/tons-of-skills-marketplace100MIT
OrcaQubits/agentic-commerce-skills-plugins100MIT

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version e06047812aa0 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100shopify-checkout-extensions
    Build Checkout UI Extensions to customize Shopify checkout with sandboxed React-like components. Use when replacing checkout.liquid (deprecated Aug 2025), adding custom fields to checkout, displaying banners, or reading checkout state with hooks. Trigger with phrases like…
  • 96shopify
    Use when the user asks to build Shopify apps, themes, or extensions.
  • 100shopify-expert
    Builds and debugs Shopify themes (.liquid files, theme.json, sections), develops custom Shopify apps (shopify.app.toml, OAuth, webhooks), and implements Storefront API integrations for headless storefronts. Use when building or customizing Shopify themes, creating Hydrogen or…
  • 100shopify-expert
    Builds and debugs Shopify themes (.liquid files, theme.json, sections), develops custom Shopify apps (shopify.app.toml, OAuth, webhooks), and implements Storefront API integrations for headless storefronts. Use when building or customizing Shopify themes, creating Hydrogen or…
  • 100shopify-payments
    Integrate Shopify payments — Shopify Payments (Stripe-powered), Payment Apps API, payment session flow, Billing API for app charges, refund processing, and PCI compliance. Use when working with Shopify payment processing.
  • 100shopify-b2b-wholesale
    Build Shopify Plus B2B features with companies, catalogs, and wholesale pricing. Use when setting up wholesale accounts, creating price lists, or configuring B2B checkout with purchase orders. Trigger with phrases like "shopify b2b", "shopify wholesale", "shopify company api",…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.