Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Loyalty: Gift Cards, Store Credits and Purchasable Gift Card Products
Status: Phase 1 in review (PR #14634) — Loyalty nav group, cross-customer store credit list and the docs restructure, for 6.0. Phase 2 (purchasable gift card products) remains 6.1 and is unbuilt.
Target: Spree 6.0 (phase 1: Loyalty group, store credit list) · Spree 6.1 (phase 2: purchasable gift card products)
Depends on: 6.0-admin-spa.md (nav registry, resource tables), 6.0-service-workflows.md (gift card workflows), 6.0-digital-assets.md (digital delivery profile, no shipment), decisions.md 2026-08-18 (store credits lose category and type)
Author: Damian + Claude
Last updated: 2026-09-14
Tracking: Linear V-3629 · GitHub spree/spree#14629
Summary
Gift cards are filed under Promotions in the dashboard nav and in the user docs, and store credits are only visible one customer at a time. Neither placement matches what the records are. A promotion is marketing: the merchant gives up margin to change behaviour. A gift card or a store credit is prepaid money the store owes, a balance on the liability side of the books that happens to reduce an order total at checkout. Every platform we compare against keeps the two apart, and so does our own data model (balances, redemption statuses, a ledger of events, and no rules or actions). This plan gives the stored-value records their own top-level Loyalty group holding Gift Cards and a new cross-customer Store Credits list, backed by a read-only admin endpoint, so a merchant can answer "how much do we owe, to whom, and why" without opening every customer. Phase 2 closes the gap every other platform already covers: a gift card as a product a shopper can buy, issued and emailed to a recipient when the order is paid.
Key Decisions (do not deviate without discussion)
Gift cards are not promotions. They leave the Promotions group in the nav, in the dashboard routes and in the docs. Promotions keeps the discount machinery (rules, actions, coupon codes) and nothing else.
The group is named Loyalty, not "Gift Cards & Credits". It ships with two real children on day one (Gift Cards, Store Credits) and is the home for a rewards or points programme later. A merchant opening it finds stored value, which is what every loyalty mechanism spends. Precedent: the hosted-platform competitor set bundles gift cards and store credit under the same word.
Store credits get a cross-customer list, read-only at the top level.
GET /api/v3/admin/store_creditsandGET /api/v3/admin/store_credits/:idlist and show across customers. Creating, editing and deleting a credit stay nested under the customer, where they are today. A credit always belongs to one customer; the list is for seeing, filtering and auditing, the way the inventory index shows stock across products while stock is still edited per product.The permission keys do not change; their group does.
gift_cardsandstore_creditsmove from theorderspermission group to a newloyaltygroup so the role sheet mirrors the nav. Key names stay, so existing roles keep working (a role holds the keys it was created with and is never re-read, see decisions.md 2026-09-09).A purchasable gift card is a product with a flag, priced by its variants. Each variant is a denomination and its price is the card's face value. The flag is what switches off everything that does not apply to prepaid money: inventory tracking, sales tax, promotions, shipping, and paying with another balance.
A card is issued when the order is paid, one per unit, by a workflow. Not at checkout completion: an order placed with a pending offline payment has not been paid for, and issuing a spendable code for it would hand out money the store has not received.
Spree::GiftCards::IssueFromOrderruns onorder.paidand is idempotent.One gift card per order stays in 6.1. The
gift_card_idcolumn on carts and orders is not replaced by a join table in this plan. Buying a gift card product needs no change to how cards are redeemed. Lifting the limit is a separate question with its own plan.2026-09-13: Phase 1 ships in 6.0, before the dashboard's first release. The
/promotions/gift-cardsroute and the docs URLs underuser/promotions/have never been public, so they move without a redirect and the docs are restructured once. Accepted cost: more on the 6.0 list.2026-09-13: The outstanding balance is
meta.totalson the filtered list. One grouped sum per currency, computed over the same scope as the page, so a customer filter shows that customer's balance and no filter shows the store's liability. Rejected: a separate balances resource (a second request that cannot follow the filters) and waiting for Reports (the list would answer "who" but not "how much"). Accepted cost: one aggregate query per list request and atotalsmember on the list meta that the SDK types carry.2026-09-13: The gift card marker is a boolean on the product.
spree_products.gift_card, one predicate for tax, promotions, inventory, shipping and balance-payment rules; every variant of such a product is a denomination. Rejected: akindon the product type (types are optional, so every check becomes a nil-safe chain and a merchant must create a type first) and a variant-level flag (moves every per-product rule to the variant and no compared platform does it). Accepted cost: one product cannot mix gift card and physical variants.2026-09-13: Recipient details get their own table.
spree_gift_card_recipients, one row per gift card line item, validated and queryable, with the cart items endpoint taking a nestedrecipientobject. Rejected: four nullable columns onspree_line_items(empty on every ordinary line of the hottest commerce table) and line itemmetadata(no validation, no index, merchant data and system data in one bag).2026-09-13: The store credit detail sheet is read-only. It shows the credit's amounts, origin, issuer, memo and its
StoreCreditEventledger, and links to the customer profile where the credit is edited. No inline memo edit on the list, which would need a write path the plan's constraints keep nested under the customer. Rejected: no sheet at all (the merchant loses the ledger, which is the "why" half of the question the list exists to answer).2026-09-13: The outstanding balance renders as one summary card per currency above the table. Each card shows outstanding, issued and used, so the breakdown has somewhere to live; a single text line or a table footer row cannot carry three figures per currency once a store trades in more than one. Cards read from the same
meta.totalsthe list returns, so they follow the active filters.
Design Details
Phase 1a: the Loyalty group
Dashboard nav (packages/dashboard/src/nav/default.ts). A new top-level entry:
nav.add({
key: 'loyalty',
labelKey: 'admin.nav.loyalty',
path: '/loyalty/gift-cards',
icon: GiftIcon,
subject: Subject.GiftCard,
position: 475, // after Sellers (450), before Promotions (500)
children: [
{ key: 'loyalty.gift-cards', labelKey: 'admin.nav.gift_cards', path: '/loyalty/gift-cards', subject: Subject.GiftCard, position: 100 },
{ key: 'loyalty.store-credits', labelKey: 'admin.nav.store_credits', path: '/loyalty/store-credits', subject: Subject.StoreCredit, position: 200 },
],
})
The promotions entry loses its only child. The group's own visibility follows the usual rule: it shows when the staff member may read either child.
Routes. routes/_authenticated/$storeId/promotions/gift-cards.tsx moves to routes/_authenticated/$storeId/loyalty/gift-cards.tsx. No redirect: the old path has never shipped. The global search's create action for gift cards and every in-app link follow the move. Subject.StoreCredit joins the subject map in @spree/dashboard-core.
Translations. admin.nav.loyalty and admin.nav.store_credits in every locale file of packages/dashboard (en, de, fr, pl, ar, zh-CN).
Permissions. In Spree::Core::PermissionConfiguration, gift_cards and store_credits register with group: :loyalty. The group is presentation only (it drives the role sheet sections); the keys and their subjects are unchanged.
Docs. The User Guide gets a Loyalty group between Customers and Promotions holding user/loyalty/gift-cards (moved from user/promotions/), user/loyalty/issue-gift-card and user/loyalty/store-credits (moved from user/customers/), plus a new page for the store credits list. The moved pages get redirects entries in docs.json because the docs site is already live for 6.0 previews. The developer page developer/core-concepts/store-credits-gift-cards stays where it is and gains a short section on the admin list endpoint. The v5 tree is untouched.
Phase 1b: the store credit list
Admin API. Spree::Api::V3::Admin::StoreCreditsController < ResourceController, scoped_resource :store_credits, routed only: [:index, :show]. Scope is current_store.store_credits. collection_includes preloads customer, created_by and originator. The nested Customers::StoreCreditsController is unchanged and remains the only write path.
Filters are Ransack on the model, extended on Spree::StoreCredit:
| Filter | Why a merchant asks |
|---|---|
customer_id, customer_email_cont |
who holds credit |
currency |
the books are per currency |
created_by_id |
who issued it |
originator_type, originator_id |
why it exists: return, exchange, claim, gift card, or manual (no originator) |
created_at range |
when it was issued |
memo_cont |
the free-text reason |
scopes available, exhausted, with_gift_card, without_gift_card |
what is still owed versus spent |
The admin serializer gains amount_authorized, display_amount_authorized, originator_type (the polymorphic shorthand, via Spree::Base.polymorphic_api_type) and originator_id (prefixed). Typelizer, Zod and OpenAPI regenerate from that.
Outstanding balance. The list's meta carries totals: one row per currency with amount, amount_used, amount_authorized and amount_remaining, computed over the filtered scope with a grouped SQL sum. Filtering by a customer therefore shows that customer's balance; the unfiltered list shows the store's liability. The dashboard renders the totals above the table.
Ledger. GET /api/v3/admin/store_credits/:store_credit_id/events lists the credit's Spree::StoreCreditEvent rows (action, amount, authorization code, originator, date) so the drill-in shows how a balance got to where it is. Read-only, gated by the store_credits key.
Dashboard. routes/_authenticated/$storeId/loyalty/store-credits.tsx renders a ResourceTable registered in tables/store-credits.tsx with columns customer (link to the profile), amount, remaining, currency, origin (return/exchange/claim/gift card/manual, linking to the originator where it has a page), issued by, memo, created. Filters match the table above. A row opens a sheet with the credit's details and its ledger. The sheet has no create form; "Issue store credit" stays on the customer profile and the empty state links there. SDK: adminClient.storeCredits.list, .get, .events.list; hook use-store-credits.ts.
Phase 2: purchasable gift card products (6.1)
Catalog. spree_products.gift_card boolean, null: false, default: false, exposed on the store and admin product serializers and writable on the admin products controller. A gift card product:
- has its variants as denominations (the variant price is the face value in the variant's currency); option type "Amount" is the convention, not a requirement;
- does not track inventory (
track_inventoryforced false on its variants); - is not taxable (no tax category; a gift card sale is a prepayment, the tax is due on what the card later buys);
- is excluded from promotions (
promotionableforced false; the existing eligibility check inSpree::Promotionalready honours it) and from price lists; - uses a digital delivery profile, so it never creates a shipment;
- cannot be paid for with a gift card or store credit (prevents turning one balance into another);
Spree::GiftCards::Applyand the store credit payment path refuse a purchase containing a gift card product; - on a marketplace belongs to the operator only; a seller cannot create one.
The dashboard product form shows a "This product is a gift card" switch that hides the inventory, tax and shipping sections when on.
Recipient. A new table spree_gift_card_recipients, one row per line item that is a gift card purchase: line_item_id, email (required), name, message, send_at (optional, store time zone), store_id. Kept off spree_line_items because recipient details exist for gift card lines only, and off metadata because they are validated, emailed and queried. The store cart items endpoint accepts recipient: { email, name, message, send_at } when the variant's product is a gift card and rejects it otherwise.
Issuance. Spree::GiftCards::IssueFromOrder runs from an order.paid subscriber. For each gift card line item it issues quantity cards: amount = variant price, currency = order currency, expires_at from a store preference (gift_card_default_validity_days, nil for never), customer nil (the code is the bearer instrument; restricting a card to a customer remains a manual admin action), created_by nil. Each card records line_item_id so the order page lists what it issued and a cancellation can find them. The workflow is idempotent: a line item that already has its cards issues nothing. gift_card.issued events carry the recipient so spree_emails (and any webhook consumer) can send the code; the buyer's confirmation shows the cards masked, never the full code.
Cancellation and refunds. Spree::Orders::Cancel cancels unused cards issued by the order through the existing cancel workflow. A card that has been partly or fully redeemed blocks a refund to the original payment for that line; the admin is offered a store credit refund instead.
Store API and storefront. Product and variant serializers expose gift_card. Cart items accept the recipient. The storefront's product page renders a denomination picker plus recipient fields for gift_card products. The customer account page lists cards the customer bought and cards assigned to them.
Migration Path
Phase 1 (6.0, before release)
- Add
Subject.StoreCredit; add theloyaltynav group; move the gift cards route; translations in all six locales. - Move
gift_cardsandstore_creditsto theloyaltypermission group. - Extend
Spree::StoreCreditRansack allowlists; add the admin store credits index/show controller, the events endpoint, themeta.totalsaggregate; serializer fields; regenerate types, Zod and OpenAPI. - Admin SDK methods,
use-store-creditshook,tables/store-credits.tsx, the route and the detail sheet. - Docs: Loyalty group in the User Guide, moved pages with redirects, the new store credits list page, the developer page section.
Phase 2 (6.1)
- Migration:
spree_products.gift_card,spree_gift_card_recipients,spree_gift_cards.line_item_id. Product model rules for the flag; admin and store serializers and controllers. - Store cart items recipient payload;
Spree::GiftCards::IssueFromOrderwith itsorder.paidsubscriber;gift_card.issuedevent serializer; cancellation hook. spree_emailsgift card mailer; dashboard product form switch and order page issued-cards card; storefront product page and account page.- Docs: user guide page "Selling gift cards", developer page update, OpenAPI.
Constraints on Current Work
- Do not add anything new under the Promotions nav group or docs group unless it is a discount mechanism. Stored value (gift cards, credits, future points) goes to Loyalty.
- Do not link to
/promotions/gift-cardsin new dashboard code; use the route constant for the gift cards page so the move is one edit. - New writes to store credits stay nested under the customer. Do not add a top-level create.
- Any new field on
Spree::StoreCreditorSpree::GiftCardthat a merchant would filter on must be added to the Ransack allowlist and the list's filter panel in the same change. - Product-level behaviour that should not apply to prepaid money (tax, promotions, inventory, shipping) must check a single predicate on the product, so phase 2 can flip it in one place. Do not introduce a second "digital-only" or "non-physical" flag that would have to be reconciled with
gift_card. - Gift card codes never appear in events, logs or the buyer-facing order payload. Only the recipient email carries the code.
- Store credit is never one of a cart's
payment_methods. It is applied throughPOST /carts/:id/store_creditsbefore the buyer chooses how to pay the rest. - A gift card and store credit are never combined on one order. Both apply paths refuse the second.
- Resize a store credit payment only through
Payment#update_store_credit_amount!. Completion takes the payment against the eligibility event recorded for its amount, so a bareupdate_column(:amount)leaves the order impossible to place.
Open Questions
The four design questions (phase 1 target, balance totals shape, gift card marker, recipient storage) were settled on 2026-09-13 and live in Key Decisions. Deferred, each with what would unblock it:
- Several gift cards on one order. Deliberately out of scope here. Unblocked by a plan of its own once phase 2 has shipped and there is demand from merchants who sell cards in small denominations.
- Open-value gift cards (the shopper types the amount). Unblocked by a decision on how a variant without a fixed price is represented; until then denominations are variants.
- A rewards or points programme under Loyalty. Unblocked by its own plan; this one only reserves the group.
References
docs/plans/6.0-admin-spa.md(nav registry, resource tables)docs/plans/6.0-service-workflows.md(gift card apply, redeem, cancel workflows)docs/plans/6.0-digital-assets.md(digital delivery profile)docs/plans/decisions.md2026-08-18 "Store credits lose their category and type", 2026-09-09 (permission keys are never re-read)docs/developer/core-concepts/store-credits-gift-cards.mdx- Competitor survey (2026-09-13, session notes): every compared platform sells gift cards as a product and none files them under discounts; the two that ship store credit pair it with gift cards.