@spree/docs 0.1.231 → 0.1.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15251,6 +15251,34 @@ components:
15251
15251
  required:
15252
15252
  - id
15253
15253
  x-typelizer: true
15254
+ StoreCreditEvent:
15255
+ type: object
15256
+ properties:
15257
+ id:
15258
+ type: string
15259
+ action:
15260
+ type: string
15261
+ authorization_code:
15262
+ type: string
15263
+ nullable: true
15264
+ display_action:
15265
+ type: string
15266
+ nullable: true
15267
+ amount:
15268
+ type: string
15269
+ display_amount:
15270
+ type: string
15271
+ created_at:
15272
+ type: string
15273
+ required:
15274
+ - id
15275
+ - action
15276
+ - authorization_code
15277
+ - display_action
15278
+ - amount
15279
+ - display_amount
15280
+ - created_at
15281
+ x-typelizer: true
15254
15282
  StoreCredit:
15255
15283
  type: object
15256
15284
  properties:
@@ -74,26 +74,22 @@ erDiagram
74
74
  | `currency` | Currency code | `USD` |
75
75
  | `memo` | Optional note about the credit | `Refund for order #R123` |
76
76
 
77
- ### Store Credit Categories
77
+ ### Why a Credit Exists
78
78
 
79
- Categories help organize store credits by their purpose:
79
+ Store credits carry no category and no type — both were retired in Spree 6.0
80
+ because neither answered a question anything asked. Two fields cover it
81
+ instead:
80
82
 
81
- | Category | Description |
82
- |----------|-------------|
83
- | Default | General purpose store credit (also the default reimbursement category) |
84
- | Expiring | Store credit that may expire |
85
- | Non-expiring | Store credit that does not expire |
83
+ | Field | What it tells you |
84
+ |-------|-------------------|
85
+ | `originator` | The return, exchange, claim or gift card that issued the credit, or nothing when an admin issued it by hand |
86
+ | `memo` | The free-text reason, written by the refund workflows or by the admin |
86
87
 
87
- > **INFO:** "Gift Card" is not a seeded category but a special name recognized by the model: any category named "Gift Card" (or one listed in `Spree::Config[:non_expiring_credit_types]`) is treated as non-expiring via `StoreCreditCategory#non_expiring?`.
88
+ Store credits do not expire; only gift cards carry an expiry, on their own
89
+ record. Which credit is spent first is decided by `Spree::StoreCredit.oldest_first`.
88
90
 
89
- ### Store Credit Types
90
-
91
- Types define the priority in which store credits are applied at checkout:
92
-
93
- | Type | Description |
94
- |------|-------------|
95
- | Expiring | Credits that may expire (applied first) |
96
- | Non-expiring | Credits that don't expire (applied last) |
91
+ > **NOTE:** `Spree::StoreCreditCategory` and `Spree::StoreCreditType` survive as deprecated
92
+ > shells for one release and are removed in 6.1. Nothing writes them.
97
93
 
98
94
  ### Store Credit Events
99
95
 
@@ -115,7 +111,7 @@ Store credits are managed in the Admin Panel:
115
111
  2. Select a customer
116
112
  3. Go to the **Store Credits** tab
117
113
  4. Click **Add Store Credit**
118
- 5. Enter the amount, category, and optional memo
114
+ 5. Enter the amount, currency, and optional memo
119
115
  6. Click **Create**
120
116
 
121
117
  Store credits can also be created via the [Admin API](../../api-reference/admin-api/introduction.md), as a nested resource under the customer:
@@ -132,7 +128,6 @@ const client = createAdminClient({
132
128
  const credit = await client.customers.storeCredits.create('cus_xxx', {
133
129
  amount: '25.00',
134
130
  currency: 'USD',
135
- category_id: 'sccat_xxx',
136
131
  memo: 'Goodwill credit for delayed shipment',
137
132
  })
138
133
  ```
@@ -141,12 +136,55 @@ const credit = await client.customers.storeCredits.create('cus_xxx', {
141
136
  spree api post /customers/cus_xxx/store_credits -d '{
142
137
  "amount": "25.00",
143
138
  "currency": "USD",
144
- "category_id": "sccat_xxx",
145
139
  "memo": "Goodwill credit"
146
140
  }'
147
141
  ```
148
142
 
149
143
 
144
+ ### Listing Store Credits Across Customers
145
+
146
+ Credits are written per customer, but read across them. The Admin API exposes a
147
+ read-only list so an integration can answer what the store owes without walking
148
+ every customer:
149
+
150
+
151
+ ```typescript Admin SDK
152
+ const { data: credits, meta } = await client.storeCredits.list({
153
+ outstanding: true,
154
+ expand: ['customer', 'created_by'],
155
+ })
156
+
157
+ // One row per currency, summed over the same filter as the page.
158
+ meta.totals.forEach((total) => {
159
+ console.log(total.currency, total.display_amount_remaining)
160
+ })
161
+ ```
162
+
163
+ ```bash CLI
164
+ spree api get /store_credits -q 'outstanding=true'
165
+ ```
166
+
167
+
168
+ Filters mirror the questions a merchant asks: `customer_id`,
169
+ `customer_email_cont`, `currency`, `created_by_id`, `memo_cont`, a
170
+ `created_at` range, and two scopes — `outstanding` (money still owed versus
171
+ money spent) and `from_gift_card` (whether a gift card redemption created it).
172
+
173
+ Each credit's ledger is its own endpoint:
174
+
175
+
176
+ ```typescript Admin SDK
177
+ const { data: events } = await client.storeCredits.events.list('credit_xxx')
178
+ ```
179
+
180
+ ```bash CLI
181
+ spree api get /store_credits/credit_xxx/events
182
+ ```
183
+
184
+
185
+ Creating, updating and deleting a credit remain nested under the customer that
186
+ holds it — a credit without an owner has nobody to pay.
187
+
150
188
  ### Store Credit Events
151
189
 
152
190
  The store credit system publishes lifecycle events:
@@ -387,10 +425,9 @@ flowchart TB
387
425
 
388
426
  ### Store Credit Priority
389
427
 
390
- When a registered customer has multiple store credits, they are applied in order of priority:
391
-
392
- 1. **Expiring credits** - Applied first to ensure they're used before expiration
393
- 2. **Non-expiring credits** - Applied after expiring credits
428
+ When a registered customer holds several store credits, the oldest is spent
429
+ first (`Spree::StoreCredit.oldest_first`). Store credits do not expire — only
430
+ gift cards carry an expiry, on their own record.
394
431
 
395
432
  ## Related Documentation
396
433
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.231",
3
+ "version": "0.1.233",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",