Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Bump @spree/sdk and @spree/next to 0.16.0

Damian Legawiec851317b8a9da
diff --git a/CLAUDE.md b/CLAUDE.md
index 221c0712c0..2736c04ceb 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -20,7 +20,7 @@ Current plans:
- `6.0-stock-reservations.md` — Time-limited stock reservations during checkout
- `6.0-typed-stock-movements.md` — Replace generic StockMovement with typed kinds + concrete FKs
- `6.0-normalize-state-to-status.md` — Rename state → status on Payment, Shipment, InventoryUnit, ReturnAuthorization, GiftCard
-- `6.0-fulfillment-and-delivery.md` — Shipment→Fulfillment, ShippingMethod→DeliveryMethod, drop ShippingCategory, FulfillmentProvider strategy
+- `6.0-fulfillment-and-delivery.md` — Shipment→Fulfillment, ShippingMethod→DeliveryMethod, drop ShippingCategory, FulfillmentProvider strategy, pickup (merchant StockLocation) + pickup_point (third-party PickupPointProvider)
- `6.0-returns-exchanges-claims.md` — First-class Return, Exchange, Claim models replacing ReturnAuthorization/Reimbursement chain
- `6.0-channels-catalogs-b2b.md` — Channel, Catalog, ProductListing (replaces StoreProduct), Company/CompanyLocation/CompanyContact for B2B
- `6.0-platform-auth.md` — Drop Devise, own auth stack, User→Customer/Staff rename
@@ -31,6 +31,7 @@ Current plans:
- `5.4-store-api-naming-standardization.md` — Standardize API naming against industry (address fields, discounts, customer_note, label, brand/last4, etc.)
- `5.4-6.0-eu-legal-compliance.md` — GDPR (data export/anonymization, consent timestamps), Omnibus (PriceHistory, lowest-in-30-days), Consumer Rights (withdrawal period). Core primitives + enterprise hooks.
+
Completed plans:
- `5.4-store-api-bridges.md` — Bridge 6.0 naming into 5.4 Store API (implemented, PR #13782)
- `spree-starter-and-create-spree-app.md` — Replace monorepo server/ with spree-starter template repo
diff --git a/docs/developer/core-concepts/orders.mdx b/docs/developer/core-concepts/orders.mdx
index b2b25c47a3..e550aa6570 100644
--- a/docs/developer/core-concepts/orders.mdx
+++ b/docs/developer/core-concepts/orders.mdx
@@ -239,24 +239,24 @@ Apply or remove promotional coupon codes during checkout:
<CodeGroup>
```typescript SDK
-// Apply a coupon
-await client.carts.couponCodes.apply(cartId, 'SAVE20')
+// Apply a discount code
+await client.carts.discountCodes.apply(cartId, 'SAVE20')
-// Remove a coupon
-await client.carts.couponCodes.remove(cartId, 'SAVE20')
+// Remove a discount code
+await client.carts.discountCodes.remove(cartId, 'SAVE20')
```
```bash cURL
-# Apply a coupon
-curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_xxx/coupon_codes' \
- -H 'Authorization: Bearer spree_pk_xxx' \
+# Apply a discount code
+curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_xxx/discount_codes' \
+ -H 'X-Spree-Api-Key: pk_xxx' \
-H 'X-Spree-Token: abc123' \
-H 'Content-Type: application/json' \
-d '{ "code": "SAVE20" }'
-# Remove a coupon
-curl -X DELETE 'https://api.mystore.com/api/v3/store/carts/cart_xxx/coupon_codes/SAVE20' \
- -H 'Authorization: Bearer spree_pk_xxx' \
+# Remove a discount code
+curl -X DELETE 'https://api.mystore.com/api/v3/store/carts/cart_xxx/discount_codes/SAVE20' \
+ -H 'X-Spree-Api-Key: pk_xxx' \
-H 'X-Spree-Token: abc123'
```
diff --git a/docs/developer/core-concepts/promotions.mdx b/docs/developer/core-concepts/promotions.mdx
index 77cb2cfd7c..11b03ab2f6 100644
--- a/docs/developer/core-concepts/promotions.mdx
+++ b/docs/developer/core-concepts/promotions.mdx
@@ -279,13 +279,13 @@ Customers apply coupon codes during checkout via the Store API:
<CodeGroup>
```typescript SDK
-// Apply a coupon code to the cart
-const cart = await client.carts.couponCodes.apply('cart_abc123', 'SUMMER20', {
+// Apply a discount code to the cart
+const cart = await client.carts.discountCodes.apply('cart_abc123', 'SUMMER20', {
spreeToken: '<token>',
})
-// Remove a coupon code from the cart
-await client.carts.couponCodes.remove('cart_abc123', 'SUMMER20', {
+// Remove a discount code from the cart
+await client.carts.discountCodes.remove('cart_abc123', 'SUMMER20', {
spreeToken: '<token>',
})
```
diff --git a/docs/developer/core-concepts/store-credits-gift-cards.mdx b/docs/developer/core-concepts/store-credits-gift-cards.mdx
index 86ae602cf4..4d0c0d0418 100644
--- a/docs/developer/core-concepts/store-credits-gift-cards.mdx
+++ b/docs/developer/core-concepts/store-credits-gift-cards.mdx
@@ -257,15 +257,21 @@ Gift cards are applied using the same coupon codes endpoint as promotion codes.
```typescript SDK
// Apply gift card code to cart (works for guests and registered customers)
-const cart = await client.carts.couponCodes.apply('cart_abc123', 'abc1234def', {
+// Gift cards use a dedicated endpoint — they reduce amount_due, not total
+const cart = await client.carts.giftCards.apply('cart_abc123', 'abc1234def', {
+ spreeToken: '<token>',
+})
+
+// Remove gift card (ID from cart.gift_card.id)
+await client.carts.giftCards.remove('cart_abc123', cart.gift_card.id, {
spreeToken: '<token>',
})
```
```bash cURL
# Apply gift card to cart (works for guests and registered customers)
-curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_abc123/coupon_codes' \
- -H 'Authorization: Bearer spree_pk_xxx' \
+curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_abc123/gift_cards' \
+ -H 'X-Spree-Api-Key: pk_xxx' \
-H 'X-Spree-Token: <token>' \
-H 'Content-Type: application/json' \
-d '{ "code": "abc1234def" }'
diff --git a/docs/developer/sdk/quickstart.mdx b/docs/developer/sdk/quickstart.mdx
index 70f622d52e..12ebdfff04 100644
--- a/docs/developer/sdk/quickstart.mdx
+++ b/docs/developer/sdk/quickstart.mdx
@@ -61,7 +61,8 @@ The SDK uses a resource builder pattern for nested resources:
| `carts` | `paymentMethods` | `list` |
| `carts` | `paymentSessions` | `create`, `get`, `update`, `complete` |
| `carts` | `fulfillments` | `list`, `update` |
-| `carts` | `couponCodes` | `apply`, `remove` |
+| `carts` | `discountCodes` | `apply`, `remove` |
+| `carts` | `giftCards` | `apply`, `remove` |
| `carts` | `storeCredits` | `apply`, `remove` |
| `customer` | `addresses` | `list`, `get`, `create`, `update`, `delete`, `markAsDefault` |
| `customer` | `creditCards` | `list`, `get`, `delete` |
diff --git a/docs/developer/sdk/store/cart-checkout.mdx b/docs/developer/sdk/store/cart-checkout.mdx
index 99349504a2..445962daf6 100644
--- a/docs/developer/sdk/store/cart-checkout.mdx
+++ b/docs/developer/sdk/store/cart-checkout.mdx
@@ -55,16 +55,26 @@ await client.carts.items.update(cartId, lineItemId, {
await client.carts.items.delete(cartId, lineItemId, options);
```
-### Coupon Codes
+### Discount Codes
```typescript
const options = { spreeToken: cart.token };
-// Apply a coupon code
-await client.carts.couponCodes.apply(cartId, 'SAVE20', options);
+// Apply a discount code
+await client.carts.discountCodes.apply(cartId, 'SAVE20', options);
-// Remove a coupon code
-await client.carts.couponCodes.remove(cartId, 'SUMMER20', options);
+// Remove a discount code
+await client.carts.discountCodes.remove(cartId, 'SAVE20', options);
+```
+
+### Gift Cards
+
+```typescript
+// Apply a gift card (reduces amount_due, not total)
+const cart = await client.carts.giftCards.apply(cartId, 'GC-ABCD-1234', options);
+
+// Remove a gift card (ID from cart.gift_card.id)
+await client.carts.giftCards.remove(cartId, 'gc_abc123', options);
```
## Checkout
diff --git a/docs/developer/storefront/nextjs/spree-next-package.mdx b/docs/developer/storefront/nextjs/spree-next-package.mdx
index 27c078f2a0..9f6309a665 100644
--- a/docs/developer/storefront/nextjs/spree-next-package.mdx
+++ b/docs/developer/storefront/nextjs/spree-next-package.mdx
@@ -120,19 +120,21 @@ Checkout functions use the implicit cart resolved from cookies. No `orderId` is
import {
getCheckout,
updateCheckout,
- getFulfillments,
selectDeliveryRate,
- applyCoupon,
- removeCoupon,
+ applyDiscountCode,
+ removeDiscountCode,
+ applyGiftCard,
+ removeGiftCard,
complete,
} from '@spree/next';
const checkout = await getCheckout();
await updateCheckout({ shipping_address: { ... }, billing_address: { ... } });
-const fulfillments = await getFulfillments();
await selectDeliveryRate(fulfillmentId, deliveryRateId);
-await applyCoupon('SAVE20');
-await removeCoupon(promotionId);
+await applyDiscountCode('SAVE20');
+await removeDiscountCode('SAVE20');
+await applyGiftCard('GC-ABCD-1234');
+await removeGiftCard('gc_abc123');
await complete();
```
diff --git a/packages/next/.changeset/gift-card-discount-code-actions.md b/packages/next/.changeset/gift-card-discount-code-actions.md
deleted file mode 100644
index 1782adca29..0000000000
--- a/packages/next/.changeset/gift-card-discount-code-actions.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-"@spree/next": minor
----
-
-Split discount codes and gift cards into separate server actions. Rename coupon actions and add dedicated gift card actions.
-
-- `applyDiscountCode(code)` — apply promotion discount code (replaces `applyCoupon`)
-- `removeDiscountCode(code)` — remove discount code (replaces `removeCoupon`)
-- `applyGiftCard(code)` — apply gift card to cart (new)
-- `removeGiftCard(giftCardId)` — remove gift card by prefixed ID (new)
diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.md
index b29c8af1f5..6b93431faa 100644
--- a/packages/next/CHANGELOG.md
+++ b/packages/next/CHANGELOG.md
@@ -1,5 +1,24 @@
# @spree/next
+## 0.16.0
+
+### Breaking Changes
+
+- **Renamed `applyCoupon` / `removeCoupon`** to `applyDiscountCode` / `removeDiscountCode`
+- All cart actions now return `CartResponse` instead of `Cart` (includes `warnings` array)
+
+### New Features
+
+- **`applyGiftCard(code)`** — apply gift card to cart
+- **`removeGiftCard(giftCardId)`** — remove gift card by prefixed ID
+- **Cart warnings** — `CartResponse.warnings` array flags items removed due to stock changes
+
+### Types
+
+- New re-exported types: `CartResponse`, `CartWarning`
+
+Requires `@spree/sdk >= 0.16.0`.
+
## 0.15.0
### Minor Changes
diff --git a/packages/next/README.md b/packages/next/README.md
index 782d3b0045..0c591c6a87 100644
--- a/packages/next/README.md
+++ b/packages/next/README.md
@@ -145,8 +145,10 @@ import {
getCheckout,
updateCheckout,
selectDeliveryRate,
- applyCoupon,
- removeCoupon,
+ applyDiscountCode,
+ removeDiscountCode,
+ applyGiftCard,
+ removeGiftCard,
complete,
} from '@spree/next';
@@ -155,8 +157,10 @@ const checkout = await getCheckout();
// checkout.fulfillments
await updateCheckout({ shipping_address: { ... }, billing_address: { ... } });
await selectDeliveryRate(fulfillmentId, rateId);
-await applyCoupon('SAVE20');
-await removeCoupon('SAVE20');
+await applyDiscountCode('SAVE20');
+await removeDiscountCode('SAVE20');
+await applyGiftCard('GC-ABCD-1234');
+await removeGiftCard('gc_abc123'); // ID from cart.gift_card.id
await complete();
```
diff --git a/packages/next/package.json b/packages/next/package.json
index de5ed42ffd..cdd9b64259 100644
--- a/packages/next/package.json
+++ b/packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/next",
- "version": "0.15.0",
+ "version": "0.16.0",
"description": "Next.js integration for Spree Commerce — server actions, caching, and cookie-based auth",
"type": "module",
"main": "./dist/index.js",
@@ -62,7 +62,7 @@
"url": "https://github.com/spree/spree/issues"
},
"peerDependencies": {
- "@spree/sdk": ">=0.15.0",
+ "@spree/sdk": ">=0.16.0",
"next": ">=15.0.0",
"react": ">=19.0.0"
},
diff --git a/packages/sdk/.changeset/gift-card-discount-code-endpoints.md b/packages/sdk/.changeset/gift-card-discount-code-endpoints.md
deleted file mode 100644
index 5a2124b4af..0000000000
--- a/packages/sdk/.changeset/gift-card-discount-code-endpoints.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-"@spree/sdk": minor
----
-
-Split discount codes and gift cards into separate cart endpoints. Rename `couponCodes` to `discountCodes` and add dedicated `giftCards` resource.
-
-- `client.carts.discountCodes.apply(cartId, code)` — apply promotion discount code (was `couponCodes.apply`)
-- `client.carts.discountCodes.remove(cartId, code)` — remove discount code (was `couponCodes.remove`)
-- `client.carts.giftCards.apply(cartId, code)` — apply gift card (new)
-- `client.carts.giftCards.remove(cartId, giftCardId)` — remove gift card by prefixed ID (new)
-
-Cart and Order types now include `amount_due` and `display_amount_due` — the amount the customer still owes after store credits/gift cards are applied.
diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md
index 8eb8ff8ce9..af37af47af 100644
--- a/packages/sdk/CHANGELOG.md
+++ b/packages/sdk/CHANGELOG.md
@@ -1,5 +1,24 @@
# @spree/sdk
+## 0.16.0
+
+### Breaking Changes
+
+- **Renamed `couponCodes` to `discountCodes`** — `client.carts.discountCodes.apply()` / `.remove()` (was `couponCodes`)
+- **Renamed `customer.passwordResets` to `passwordResets`** — moved to top-level: `client.passwordResets.create()` / `.update()`
+
+### New Features
+
+- **Gift cards** — dedicated cart endpoints: `client.carts.giftCards.apply(cartId, code)` and `client.carts.giftCards.remove(cartId, giftCardId)`
+- **`amount_due` / `display_amount_due`** — new fields on Cart and Order types showing the amount owed after store credits/gift cards
+- **Cart warnings** — every cart response now includes a `warnings` array flagging issues like removed out-of-stock items. New types: `CartWarning`, `CartResponse`
+- **Gift card error codes** — dedicated error codes: `gift_card_not_found`, `gift_card_expired`, `gift_card_already_redeemed`
+
+### Types
+
+- All cart endpoints now return `CartResponse` (= `Cart & { warnings: CartWarning[] }`)
+- New exported types: `CartWarning`, `CartResponse`
+
## 0.15.0
### Minor Changes
diff --git a/packages/sdk/README.md b/packages/sdk/README.md
index fe9d3016ca..464eb634fa 100644
--- a/packages/sdk/README.md
+++ b/packages/sdk/README.md
@@ -259,16 +259,33 @@ await client.carts.items.update('cart_xxx', lineItemId, {
await client.carts.items.delete('cart_xxx', lineItemId, options);
```
-### Coupon Codes
+### Discount Codes
```typescript
const options = { spreeToken: cart.token };
-// Apply a coupon code
-await client.carts.couponCodes.apply('cart_xxx', 'SAVE20', options);
+// Apply a discount code
+await client.carts.discountCodes.apply('cart_xxx', 'SAVE20', options);
-// Remove a coupon code
-await client.carts.couponCodes.remove('cart_xxx', 'SAVE20', options);
+// Remove a discount code
+await client.carts.discountCodes.remove('cart_xxx', 'SAVE20', options);
+```
+
+### Gift Cards
+
+```typescript
+const options = { spreeToken: cart.token };
+
+// Apply a gift card
+const cart = await client.carts.giftCards.apply('cart_xxx', 'GC-ABCD-1234', options);
+
+// Remove a gift card (ID from cart.gift_card.id)
+await client.carts.giftCards.remove('cart_xxx', 'gc_abc123', options);
+
+// Check cart warnings (e.g. items removed due to stock changes)
+if (cart.warnings.length > 0) {
+ cart.warnings.forEach(w => console.log(w.code, w.message));
+}
```
### Fulfillments
@@ -465,12 +482,12 @@ await client.customer.addresses.update('addr_xxx', { is_default_billing: true },
await client.customer.addresses.update('addr_xxx', { is_default_shipping: true }, options);
```
-### Customer Password Resets
+### Password Resets
```typescript
// Request a password reset email
// Always returns { message: string } (202 status) — prevents email enumeration
-await client.customer.passwordResets.create({
+await client.passwordResets.create({
redirect_url: 'https://myshop.com/reset-password', // optional, validated against store's allowed origins
});
@@ -478,7 +495,7 @@ await client.customer.passwordResets.create({
// Reset password with token from email
// Returns AuthTokens (JWT + user) — auto-login on success
// Token expires in 15 minutes
-const { token, user } = await client.customer.passwordResets.update('reset_token_xxx', {
+const { token, user } = await client.passwordResets.update('reset_token_xxx', {
password: 'newPassword123',
password_confirmation: 'newPassword123',
});
@@ -554,13 +571,14 @@ The SDK uses a resource builder pattern for nested resources:
| Parent Resource | Nested Resource | Available Methods |
|-----------------|-----------------|-------------------|
| `carts` | `items` | `create`, `update`, `delete` |
-| `carts` | `couponCodes` | `apply`, `remove` |
+| `carts` | `discountCodes` | `apply`, `remove` |
+| `carts` | `giftCards` | `apply`, `remove` |
| `carts` | `fulfillments` | `update` |
| `carts` | `payments` | `create` |
| `carts` | `paymentSessions` | `create`, `get`, `update`, `complete` |
| `carts` | `storeCredits` | `apply`, `remove` |
+| `passwordResets` | — | `create`, `update` |
| `customer` | `addresses` | `list`, `get`, `create`, `update`, `delete` |
-| `customer` | `passwordResets` | `create`, `update` |
| `customer` | `creditCards` | `list`, `get`, `delete` |
| `customer` | `giftCards` | `list`, `get` |
| `customer` | `storeCredits` | `list`, `get` |
@@ -573,7 +591,7 @@ Example:
```typescript
// Cart resources take cartId as first argument
await client.carts.items.create(cartId, params, options);
-await client.carts.couponCodes.apply(cartId, code, options);
+await client.carts.discountCodes.apply(cartId, code, options);
await client.carts.fulfillments.update(cartId, fulfillmentId, params, options);
await client.carts.payments.create(cartId, params, options);
await client.carts.paymentSessions.create(cartId, params, options);
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index daa0093856..9815b098bf 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/sdk",
- "version": "0.15.0",
+ "version": "0.16.0",
"description": "Official TypeScript SDK for Spree Commerce Store API",
"type": "module",
"main": "./dist/index.cjs",