Built with AI 08 · Shopify Function · Checkout UI extension

Wholesale Tiers

Approved wholesale customers get 10% off at 12+ units, 15% at 24+ and 20% at 48+, applied automatically at checkout. A progress bar shows how many more units unlock the next tier. The merchant approves customers in the admin; tiers live in one config read by both the Function and the checkout block.

builds · wasm tests 10/10 · unit tests 12/12Shopify validators passnot yet on a dev storeDiscount Function API 2026-07Preact + Polaris web components

Cart simulator

Change quantities and the customer's approval. The page builds the exact input the Function receives at checkout, runs the real Function code from the repo, and applies its output. The progress block uses the same logic as the checkout extension.

● cart.lines.discounts.generate.run · tiers 12 / 24 / 48 → 10 / 15 / 20%runs in your browser
Function input (what Shopify sends)
Function output (what the code returned)

Checkout

How it decides

customer.$app:wholesale_approved == "true"?        no → no discount
eligible lines = product variants without the "no-wholesale" tag
units          = sum of eligible quantities
tier           = highest tier in shop.$app:wholesale_tiers with minQuantity ≤ units
→ one product discount on every eligible line: "Wholesale 15% (24+ units)"

AI build log

Built with Claude Code (Opus 5.5), Shopify's AI Toolkit (docs search + validators), Shopify CLI 5.1 and Shopify's own extension templates. The spec was mine; the code was the agent's; every row below is a check that ran.

StepResult
Input query validated against the Discount Function schema 2026-07✓
Function + 10 fixtures (guest, not approved, below tier, each tier, mixed cart with excluded and custom items, wrong discount class, missing / broken config)12/12 unit tests
First shopify app function build✗ [auth]: Required in the app config → added
Second build✗ GraphQL codegen had no config — the agent had trimmed the template's codegen block → restored
Third build✓ function.wasm, 3.2 KB
All 10 fixtures through the compiled wasm with Shopify's test harness (also validates fixtures against the schema)10/10
Checkout extension, first validation✗ s-progress got string | any[] as its accessibility label — i18n.translate() can return an array. A real screen-reader bug → fixed
Checkout extension, second validation✓ s-banner, s-stack, s-text, s-progress
shopify app build (both extensions)✓ checkout bundle ≈ 7.8 KB compressed
Setup mutations (discountAutomaticAppCreate, metafieldsSet) validated against Admin API 2026-07✓

Three of the ten steps failed first time. That is the normal ratio — and why the checks are part of the service, not an extra.

Known gaps