gift-cards
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGift Cards
礼品卡
Overview
概述
Gift cards let customers purchase store credit to give as gifts or to use themselves. They function as a form of payment at checkout — a customer can pay part of an order with a gift card and the remainder with a credit card, and any unused balance stays on the card. All major e-commerce platforms include native gift card functionality; custom implementations are only needed for headless storefronts or very specific accounting requirements.
礼品卡允许顾客购买商店信用额度,用于送礼或自用。它们可作为结账时的支付方式——顾客可以用礼品卡支付部分订单金额,剩余部分用信用卡支付,未使用的余额将保留在卡内。所有主流电商平台都包含原生礼品卡功能;仅在无头店面或有特殊会计需求的情况下才需要自定义实现。
When to Use This Skill
何时使用该技能
- When adding gift cards as a purchasable product that customers can send to others
- When implementing store credit as a refund mechanism in place of cash refunds
- When building bulk corporate gift card programs for B2B clients
- When allowing customers to split payment between a gift card and a credit card at checkout
- When you need a full balance history for accounting reconciliation or customer support
- 当添加礼品卡作为可购买产品,供顾客赠予他人时
- 当将商店信用额度作为退款机制替代现金退款时
- 为B2B客户构建批量企业礼品卡项目时
- 允许顾客在结账时拆分礼品卡与信用卡支付时
- 需要完整余额历史记录用于会计对账或客户支持时
Core Instructions
核心操作指南
Step 1: Determine the merchant's platform and choose the right tool
步骤1:确定商家平台并选择合适工具
| Platform | Recommendation | Notes |
|---|---|---|
| Shopify | Use Shopify's built-in gift cards (available on all plans except Basic) | Native integration with checkout, balance tracking, and email delivery — no app needed |
| WooCommerce | WooCommerce Gift Cards plugin (official, | Core WooCommerce does not include gift cards; these plugins are well-maintained and widely used |
| BigCommerce | BigCommerce Gift Certificates (built in, all plans) | Native support — create, sell, and redeem gift certificates from the admin panel |
| Custom / Headless | Build with ledger-based balance tracking | See Custom section below |
| 平台 | 推荐方案 | 说明 |
|---|---|---|
| Shopify | 使用Shopify内置礼品卡功能(除Basic套餐外,所有套餐均支持) | 与结账系统原生集成,支持余额追踪和邮件发送——无需额外应用 |
| WooCommerce | WooCommerce Gift Cards插件(官方版,约49美元/年)或YITH WooCommerce Gift Cards(约80美元/年) | 核心WooCommerce不包含礼品卡功能;这些插件维护良好且被广泛使用 |
| BigCommerce | BigCommerce Gift Certificates(内置功能,所有套餐均支持) | 原生支持——可从管理面板创建、售卖和兑换礼品券 |
| 自定义/无头平台 | 基于账本式余额追踪构建 | 详见下方自定义部分 |
Step 2: Set up gift cards on your platform
步骤2:在平台上设置礼品卡
Shopify
Shopify
Shopify gift cards are available on Shopify, Advanced, and Plus plans (not Basic). They are issued as a product and redeemed at checkout using a 16-character code.
Enable and create gift cards:
- In your Shopify admin, go to Products → Gift cards
- Click Add gift card product
- Set denominations (e.g., $25, $50, $100) — each denomination is a product variant
- Add a title, description, and image for the gift card product
- Click Save
Issuing a gift card to a customer:
- Via sale: When a customer purchases a gift card, Shopify automatically generates a unique code and emails it to the recipient
- Manually: Go to Customers → find the customer → Gift cards tab → Issue gift card; set the value and expiry date
Setting expiry dates:
- In Settings → Gift cards
- Enable gift card expiry and set the default expiration period
- Note: Some jurisdictions prohibit gift card expiry (check local law before enabling)
Bulk gift cards for B2B or marketing:
- Go to Products → Gift cards → Export to download existing codes
- Use the Shopify Admin API () to bulk-create gift cards programmatically
POST /admin/api/2024-04/gift_cards.json - The API response includes the code — distribute via your email platform
Store credit as a refund:
When issuing a refund, Shopify allows you to refund to a gift card instead of the original payment method:
- Go to Orders → open the order → Refund
- Under "Refund to", select Gift card and specify the amount
- Shopify creates a new gift card and emails the code to the customer
Shopify礼品卡适用于Shopify、Advanced和Plus套餐(Basic套餐不支持)。它们作为产品发行,结账时使用16位代码兑换。
启用并创建礼品卡:
- 在Shopify管理后台,进入Products → Gift cards
- 点击Add gift card product
- 设置面额(如25美元、50美元、100美元)——每个面额对应一个产品变体
- 添加礼品卡产品的标题、描述和图片
- 点击Save
向顾客发行礼品卡:
- 通过售卖: 当顾客购买礼品卡时,Shopify自动生成唯一代码并发送至收件人邮箱
- 手动发行: 进入Customers → 找到对应顾客 → Gift cards标签页 → Issue gift card;设置金额和有效期
设置有效期:
- 进入Settings → Gift cards
- 启用礼品卡有效期并设置默认有效期时长
- 注意:部分地区禁止礼品卡设置有效期(启用前请查阅当地法规)
面向B2B或营销场景的批量礼品卡:
- 进入Products → Gift cards → Export下载现有代码
- 使用Shopify Admin API()以编程方式批量创建礼品卡
POST /admin/api/2024-04/gift_cards.json - API响应包含卡片代码——通过你的邮件平台分发
将商店信用额度作为退款方式:
退款时,Shopify允许你将退款金额退至礼品卡而非原支付方式:
- 进入Orders → 打开对应订单 → Refund
- 在“Refund to”下选择Gift card并指定金额
- Shopify将创建新礼品卡并将代码发送至顾客邮箱
WooCommerce
WooCommerce
Install the WooCommerce Gift Cards extension (from WooCommerce.com) or YITH WooCommerce Gift Cards. These are the most feature-complete options.
Setup with WooCommerce Gift Cards:
- Install and activate the plugin
- Go to Products → Add New and set the product type to Gift card
- Under Gift card data:
- Set delivery type: email delivery (for digital) or printed card
- Set available amounts or allow custom amounts
- Configure the email template that sends the code to the recipient
- Publish the product
Redemption:
The plugin adds a "Gift card" field to the checkout page. Customers enter their code and the balance is deducted from the order total. Partial redemption is supported — remaining balance stays on the card.
Store credit as refund:
- Open the order → Refund
- The plugin adds a "Refund to gift card" option
- A new gift card code is generated and emailed to the customer
Balance inquiry:
Both WooCommerce Gift Cards and YITH provide a balance inquiry shortcode you can add to a page:
[woo_gift_card_balance_check]安装WooCommerce Gift Cards扩展(来自WooCommerce.com)或YITH WooCommerce Gift Cards。这些是功能最完善的选项。
使用WooCommerce Gift Cards设置:
- 安装并激活插件
- 进入Products → Add New,将产品类型设置为Gift card
- 在Gift card data下:
- 设置配送类型:邮件配送(数字卡)或实体印刷卡
- 设置可选金额或允许自定义金额
- 配置发送卡片代码给收件人的邮件模板
- 发布产品
兑换流程:
插件会在结账页面添加“Gift card”输入框。顾客输入代码后,余额将从订单总额中扣除。支持部分兑换——剩余余额保留在卡内。
将退款退至礼品卡:
- 打开订单 → Refund
- 插件会添加“Refund to gift card”选项
- 系统将生成新礼品卡代码并发送至顾客邮箱
余额查询:
WooCommerce Gift Cards和YITH均提供余额查询短代码,可添加至页面:
[woo_gift_card_balance_check]BigCommerce
BigCommerce
BigCommerce calls these "Gift Certificates" and includes them natively.
Create and sell gift certificates:
- Go to Marketing → Gift Certificates → Create Gift Certificate
- Fill in:
- To (recipient name and email)
- From (sender name and email)
- Amount: fixed value
- Expiry date (optional)
- BigCommerce sends the certificate code to the recipient via email
Selling gift certificates as a product:
- Go to Products → Gift Certificates
- Enable the gift certificate product page
- Customers can purchase certificates in custom or fixed amounts directly from your storefront
Redemption:
Gift certificate codes appear as a payment option at checkout. Partial redemption is supported — the remaining balance is saved on the certificate code.
BigCommerce将其称为“Gift Certificates”,并提供原生支持。
创建并售卖礼品券:
- 进入Marketing → Gift Certificates → Create Gift Certificate
- 填写信息:
- To(收件人姓名和邮箱)
- From(发件人姓名和邮箱)
- Amount:固定金额
- Expiry date(可选)
- BigCommerce将通过邮件向收件人发送礼品券代码
将礼品券作为产品售卖:
- 进入Products → Gift Certificates
- 启用礼品券产品页面
- 顾客可直接从店面购买自定义或固定金额的礼品券
兑换流程:
礼品券代码会作为支付选项出现在结账页面。支持部分兑换——剩余余额将保留在礼品券代码中。
Custom / Headless
自定义/无头平台
For headless storefronts, implement a ledger-based gift card system. The ledger pattern records every debit and credit as an immutable transaction row — never update a balance column directly.
sql
CREATE TABLE gift_cards (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
code VARCHAR(32) NOT NULL UNIQUE,
initial_value_cents INTEGER NOT NULL,
currency VARCHAR(3) NOT NULL DEFAULT 'USD',
issued_to VARCHAR(255),
expires_at TIMESTAMPTZ,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE gift_card_ledger (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
card_id UUID NOT NULL REFERENCES gift_cards(id),
amount_cents INTEGER NOT NULL, -- positive = credit, negative = debit
type VARCHAR(16) NOT NULL CHECK (type IN ('issue', 'redeem', 'refund', 'void')),
order_id UUID,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);Balance calculation — always derived from the ledger, never from a stored column:
typescript
async function getBalance(cardCode: string): Promise<number> {
const card = await db.giftCards.findByCode(cardCode.toUpperCase());
if (!card || !card.is_active) throw new Error('CARD_NOT_FOUND');
if (card.expires_at && card.expires_at < new Date()) throw new Error('CARD_EXPIRED');
const result = await db.raw(
'SELECT COALESCE(SUM(amount_cents), 0) AS balance FROM gift_card_ledger WHERE card_id = ?',
[card.id]
);
return Math.max(0, parseInt(result.rows[0].balance, 10));
}Partial redemption with row-level locking to prevent concurrent over-redemption:
typescript
async function redeemGiftCard(code: string, orderId: string, orderTotalCents: number) {
return db.transaction(async tx => {
// Lock the card row to prevent concurrent redemptions
const card = await tx.raw(
'SELECT * FROM gift_cards WHERE UPPER(code) = ? FOR UPDATE',
[code.toUpperCase()]
).then(r => r.rows[0]);
if (!card || !card.is_active) throw new Error('CARD_NOT_FOUND');
const balance = await getBalance(code);
const appliedCents = Math.min(balance, orderTotalCents);
if (appliedCents === 0) throw new Error('ZERO_BALANCE');
await tx.giftCardLedger.insert({
card_id: card.id,
amount_cents: -appliedCents,
type: 'redeem',
order_id: orderId,
});
return { appliedCents, remainingBalance: balance - appliedCents };
});
}对于无头店面,需实现基于账本的礼品卡系统。账本模式会将每笔借记和贷记记录为不可变的交易行——切勿直接更新余额列。
sql
CREATE TABLE gift_cards (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
code VARCHAR(32) NOT NULL UNIQUE,
initial_value_cents INTEGER NOT NULL,
currency VARCHAR(3) NOT NULL DEFAULT 'USD',
issued_to VARCHAR(255),
expires_at TIMESTAMPTZ,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE gift_card_ledger (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
card_id UUID NOT NULL REFERENCES gift_cards(id),
amount_cents INTEGER NOT NULL, -- positive = credit, negative = debit
type VARCHAR(16) NOT NULL CHECK (type IN ('issue', 'redeem', 'refund', 'void')),
order_id UUID,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);余额计算 —— 始终从账本派生,切勿使用存储的余额列:
typescript
async function getBalance(cardCode: string): Promise<number> {
const card = await db.giftCards.findByCode(cardCode.toUpperCase());
if (!card || !card.is_active) throw new Error('CARD_NOT_FOUND');
if (card.expires_at && card.expires_at < new Date()) throw new Error('CARD_EXPIRED');
const result = await db.raw(
'SELECT COALESCE(SUM(amount_cents), 0) AS balance FROM gift_card_ledger WHERE card_id = ?',
[card.id]
);
return Math.max(0, parseInt(result.rows[0].balance, 10));
}带有行级锁的部分兑换 以防止并发超额兑换:
typescript
async function redeemGiftCard(code: string, orderId: string, orderTotalCents: number) {
return db.transaction(async tx => {
// Lock the card row to prevent concurrent redemptions
const card = await tx.raw(
'SELECT * FROM gift_cards WHERE UPPER(code) = ? FOR UPDATE',
[code.toUpperCase()]
).then(r => r.rows[0]);
if (!card || !card.is_active) throw new Error('CARD_NOT_FOUND');
const balance = await getBalance(code);
const appliedCents = Math.min(balance, orderTotalCents);
if (appliedCents === 0) throw new Error('ZERO_BALANCE');
await tx.giftCardLedger.insert({
card_id: card.id,
amount_cents: -appliedCents,
type: 'redeem',
order_id: orderId,
});
return { appliedCents, remainingBalance: balance - appliedCents };
});
}Best Practices
最佳实践
- Use an append-only ledger — never update a balance column; record every debit and credit as a transaction row for a full audit trail (required for accounting reconciliation)
- Generate codes without ambiguous characters — omit ,
0,O,1from the character set to prevent customer confusion when reading codes from emailI - Never expose full card codes in URLs or logs — partial masking () is safe for display; full codes belong only in the issuance email
ABCD-xxxx-xxxx-MNOP - Set accounting liabilities on issuance — gift card balances are a deferred revenue liability until redeemed; ensure your accounting integration records this correctly
- Check local regulations before setting expiry dates — many US states and other jurisdictions restrict or prohibit gift card expiration; verify before enabling
- Test the refund-to-gift-card flow — this is a common customer service scenario; ensure the newly issued card is accessible and redeemable before going live
- 使用追加式账本 —— 切勿更新余额列;将每笔借记和贷记记录为交易行,以保留完整审计轨迹(会计对账所需)
- 生成无歧义字符的代码 —— 从字符集中排除、
0、O、1,避免顾客从邮件中读取代码时产生混淆I - 切勿在URL或日志中暴露完整卡片代码 —— 部分掩码(如)可安全显示;完整代码仅应出现在发行邮件中
ABCD-xxxx-xxxx-MNOP - 发行时设置会计负债 —— 礼品卡余额在兑换前属于递延收入负债;确保你的会计集成正确记录此事项
- 设置有效期前查阅当地法规 —— 美国多个州及其他地区限制或禁止礼品卡设置有效期;启用前请核实
- 测试退款至礼品卡的流程 —— 这是常见的客户服务场景;上线前确保新发行的卡片可访问且可兑换
Common Pitfalls
常见问题与解决方案
| Problem | Solution |
|---|---|
| Two simultaneous checkouts both succeed using the same card | Use a row-level lock ( |
| Balance goes negative due to rounding in split payment | Use |
| Customer cannot find their card after a refund re-credits it | After refunding to a gift card, ensure the card is reactivated if it was previously depleted and deactivated |
| Gift card codes appear in server access logs | Never include the code as a URL path parameter; use a POST body or a hashed lookup token |
| Gift card purchased but code not delivered | Platform-native gift cards send automatically; for custom implementations, use transactional email with delivery tracking and a resend option in your customer service panel |
| 问题 | 解决方案 |
|---|---|
| 同一卡片被用于两个同时进行的结账且均成功 | 在读取余额前,在数据库事务中使用行级锁( |
| 拆分支付时因四舍五入导致余额为负 | 使用 |
| 退款重新入账后顾客找不到卡片 | 退款至礼品卡后,若卡片此前已耗尽并停用,需确保卡片重新激活 |
| 礼品卡代码出现在服务器访问日志中 | 切勿将代码作为URL路径参数;使用POST请求体或哈希查找令牌 |
| 购买礼品卡但未收到代码 | 平台原生礼品卡会自动发送;自定义实现需使用带送达追踪的事务邮件,并在客户服务面板中提供重发选项 |
Related Skills
相关技能
- @coupon-management
- @loyalty-points-system
- @stripe-integration
- @returns-management
- @checkout-flow-optimization
- @coupon-management
- @loyalty-points-system
- @stripe-integration
- @returns-management
- @checkout-flow-optimization