@spree/docs 0.1.80 → 0.1.82

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.
Files changed (31) hide show
  1. package/dist/api-reference/store-api/errors.md +3 -3
  2. package/dist/api-reference/store-api/idempotency.md +1 -1
  3. package/dist/developer/cli/quickstart.md +149 -1
  4. package/dist/developer/contributing/creating-an-extension.md +1 -1
  5. package/dist/developer/contributing/developing-spree.md +167 -76
  6. package/dist/developer/core-concepts/addresses.md +10 -10
  7. package/dist/developer/core-concepts/adjustments.md +1 -1
  8. package/dist/developer/core-concepts/customers.md +1 -1
  9. package/dist/developer/core-concepts/events.md +12 -6
  10. package/dist/developer/core-concepts/markets.md +10 -10
  11. package/dist/developer/core-concepts/media.md +2 -2
  12. package/dist/developer/core-concepts/orders.md +10 -10
  13. package/dist/developer/core-concepts/pricing.md +2 -2
  14. package/dist/developer/core-concepts/products.md +12 -12
  15. package/dist/developer/core-concepts/promotions.md +1 -1
  16. package/dist/developer/core-concepts/search-filtering.md +11 -11
  17. package/dist/developer/core-concepts/shipments.md +2 -2
  18. package/dist/developer/core-concepts/slugs.md +4 -4
  19. package/dist/developer/core-concepts/stores.md +1 -1
  20. package/dist/developer/core-concepts/translations.md +1 -1
  21. package/dist/developer/core-concepts/users.md +1 -1
  22. package/dist/developer/create-spree-app/quickstart.md +8 -7
  23. package/dist/developer/customization/checkout.md +1 -1
  24. package/dist/developer/customization/decorators.md +10 -8
  25. package/dist/developer/customization/quickstart.md +1 -1
  26. package/dist/developer/deployment/environment_variables.md +1 -1
  27. package/dist/developer/how-to/custom-order-routing.md +18 -3
  28. package/dist/developer/sdk/store/markets.md +5 -5
  29. package/dist/developer/tutorial/extending-models.md +1 -1
  30. package/dist/developer/upgrades/5.4-to-5.5.md +84 -17
  31. package/package.json +1 -1
@@ -25,7 +25,7 @@ markets.forEach(market => {
25
25
 
26
26
  ```bash cURL
27
27
  curl 'https://api.mystore.com/api/v3/store/markets' \
28
- -H 'Authorization: Bearer pk_xxx'
28
+ -H 'X-Spree-API-Key: pk_xxx'
29
29
  ```
30
30
 
31
31
 
@@ -76,7 +76,7 @@ market.countries // [{ iso: "DE", ... }, { iso: "FR", ... }]
76
76
 
77
77
  ```bash cURL
78
78
  curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB' \
79
- -H 'Authorization: Bearer pk_xxx'
79
+ -H 'X-Spree-API-Key: pk_xxx'
80
80
  ```
81
81
 
82
82
 
@@ -95,7 +95,7 @@ market.currency // "EUR"
95
95
 
96
96
  ```bash cURL
97
97
  curl 'https://api.mystore.com/api/v3/store/markets/resolve?country=DE' \
98
- -H 'Authorization: Bearer pk_xxx'
98
+ -H 'X-Spree-API-Key: pk_xxx'
99
99
  ```
100
100
 
101
101
 
@@ -119,7 +119,7 @@ countries.forEach(country => {
119
119
 
120
120
  ```bash cURL
121
121
  curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB/countries' \
122
- -H 'Authorization: Bearer pk_xxx'
122
+ -H 'X-Spree-API-Key: pk_xxx'
123
123
  ```
124
124
 
125
125
 
@@ -140,7 +140,7 @@ country.states // [{ id: "st_xxx", name: "New York", abbr: "NY" }, ...]
140
140
 
141
141
  ```bash cURL
142
142
  curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB/countries/US?expand=states' \
143
- -H 'Authorization: Bearer pk_xxx'
143
+ -H 'X-Spree-API-Key: pk_xxx'
144
144
  ```
145
145
 
146
146
 
@@ -289,7 +289,7 @@ module MyApp
289
289
  subscribes_to 'product.updated'
290
290
 
291
291
  def handle(event)
292
- product = Spree::Product.find_by(id: event.payload['id'])
292
+ product = Spree::Product.find_by_prefix_id(event.payload['id'])
293
293
  return unless product
294
294
 
295
295
  ExternalSyncService.sync(product)
@@ -5,23 +5,51 @@ description: Step-by-step guide to upgrading a Spree 5.4 application to Spree 5.
5
5
 
6
6
  > **INFO:** Before proceeding to upgrade, please ensure you're at [Spree 5.4](5.3-to-5.4.md).
7
7
 
8
- ## Upgrade steps
8
+ The upgrade is usually completed in five steps:
9
9
 
10
- ### Update gems
10
+ 1. **Update the Ruby gems** which power Spree API
11
+ 2. **Run database migrations** — to migrate your existing schema to the new version
12
+ 3. **Run data backfills** — to move your existing data into the new schema and power new features
13
+ 4. Apply optional configuration and review behavior changes — to take advantage of new features and avoid surprises
11
14
 
12
- ```bash
13
- bundle update
14
- ```
15
+ ## How to upgrade
15
16
 
16
- ### Fetch and run missing migrations
17
+ For applications created via `create-spree-app` command we greatly recommend using the Spree CLI to perform the upgrade. It provides a guided experience with prompts and handles the first three steps for you. If you prefer to run the commands manually or not using docker for local development, you can follow the "Without Spree CLI" path.
17
18
 
18
- ```bash
19
- bin/rake spree:install:migrations && bin/rails db:migrate
20
- ```
19
+
20
+ ```bash Spree CLI
21
+ spree upgrade
22
+ ```
23
+
24
+ ```bash Without Spree CLI
25
+ # cd backend if you're in the monorepo root
26
+ bundle update
27
+ bin/rake spree:install:migrations && bin/rails db:migrate
28
+ bin/rake spree:upgrade
29
+ ```
30
+
31
+
32
+ The **Spree CLI** path runs all three commands for you with prompts. Recommended for local development. If you don't have the CLI yet, either install it globally or run it through `npx`:
33
+
34
+ ```bash
35
+ # install once and use `spree …` everywhere
36
+ npm install -g @spree/cli
37
+
38
+ # or invoke without installing (each command runs through npx)
39
+ npx @spree/cli upgrade
40
+ ```
41
+
42
+ The **Without Spree CLI** path is the bare equivalent. Use this on production: `bundle update` and `db:migrate` are part of your existing deploy pipeline (Heroku release phase, K8s init container, Capistrano hook, Render auto-migrate). Once the 5.5 release is up, run `bin/rake spree:upgrade` from a one-off dyno / job container / `kubectl exec` to perform the data backfills.
43
+
44
+ Skipping versions and re-running are both safe — `bin/rake spree:upgrade` figures out what still needs to happen and does nothing on data that's already migrated.
45
+
46
+ ## What the upgrade does
47
+
48
+ This is reference material — what `bin/rake spree:upgrade` (and equivalently `spree upgrade`) actually executes on your data. Skip if you trust the tool; read on if something failed or you're curious.
21
49
 
22
50
  ### Migrate legacy variant-pinned media
23
51
 
24
- In 5.5 the [product is the default owner of media](../core-concepts/media.md#product-level-gallery). Existing variant-pinned images keep rendering, but new admin uploads attach to the product. To consolidate both into a single gallery, run:
52
+ In 5.5 the [product is the default owner of media](../core-concepts/media.md#product-level-gallery). Existing variant-pinned images keep rendering, but new admin uploads attach to the product. To consolidate both into a single gallery, the upgrade runs:
25
53
 
26
54
  ```bash
27
55
  bin/rails spree:media:migrate_master_images_to_product_media
@@ -41,7 +69,7 @@ bin/rails spree:media:migrate_master_images_to_product_media BATCH_SIZE=1000
41
69
 
42
70
  Spree 5.5 introduces [Sales Channels](../core-concepts/channels.md) — a per-store distribution surface (online storefront, POS, marketplace integration, wholesale portal). Products are published to a channel via the new `spree_product_publications` join table, and orders are attributed to a channel via `spree_orders.channel_id`.
43
71
 
44
- The migrations add a `default` boolean on `spree_channels`, a `store_id` column on `spree_products`, and create the new `spree_product_publications` table — **but they do not seed default channels, attach existing products to a store, or backfill order channels**. That work is done by an idempotent rake task you must run after `db:migrate`:
72
+ The migrations add a `default` boolean on `spree_channels`, a `store_id` column on `spree_products`, and create the new `spree_product_publications` table — **but they do not seed default channels, attach existing products to a store, or backfill order channels**. That work is done by an idempotent rake task:
45
73
 
46
74
  ```bash
47
75
  bin/rake spree:channels:upgrade
@@ -58,13 +86,23 @@ The task is fully idempotent — safe to re-run if it fails partway, and a no-op
58
86
 
59
87
  > **WARNING:** Until `spree:channels:upgrade` runs, every product has `store_id IS NULL` and is invisible to `Product.for_store(store)`. The admin product list, storefront catalog, and search indexer all return empty. Run the task immediately after `db:migrate`.
60
88
 
89
+ ### Reindex products
90
+
91
+ The last step rebuilds the search index against the configured [search provider](../core-concepts/search-filtering.md):
92
+
93
+ ```bash
94
+ bin/rake spree:search:reindex
95
+ ```
96
+
97
+ This is a no-op on the default Database provider (there is no external index to maintain). For Meilisearch — or any other external search provider — it is required, and it must run **after** the Channels upgrade: products only become visible to `Product.for_store` once they have a `store_id`, so reindexing before the channels step would index zero products. The manifest orders the steps accordingly.
98
+
61
99
  #### Multi-store catalogs
62
100
 
63
101
  If you have products attached to multiple stores via the legacy `spree_products_stores` join, the `populate_publications` task picks **one** "home" store per product and creates publications on every store's default channel. The `spree_products_stores` table is **kept** as legacy compat surface — the upcoming `spree_multi_store` extension restores the full `Product has_many :stores` association on top of it.
64
102
 
65
103
  For single-store deployments this is invisible; you can move on without touching `spree_products_stores` again.
66
104
 
67
- #### Behavioral changes
105
+ #### Behavioral changes from the Channels upgrade
68
106
 
69
107
  - Newly-created products in **the dashboard SPA** are auto-published on the store's default channel; the merchant can untick channels post-create via the Publishing card.
70
108
  - Newly-created products via the **Admin API** are NOT auto-published — the caller must supply `product_publications: [{ channel_id }]` on create or use `POST /api/v3/admin/channels/:id/add_products` afterwards.
@@ -73,6 +111,29 @@ For single-store deployments this is invisible; you can move on without touching
73
111
 
74
112
  Orders modified after the upgrade auto-set `channel_id` via the model's `before_validation :ensure_channel_presence` callback, so `backfill_order_channel_ids` is only strictly required for orders that aren't touched again post-upgrade — but running it at upgrade time avoids surprises later. The legacy `channel` string column is **kept** on `spree_orders` and ignored by ActiveRecord (`Spree::Order` declares it in `ignored_columns`). It will be dropped in a later Spree release once everyone has had a chance to run the backfill.
75
113
 
114
+ ## Update the Spree SDK
115
+
116
+ Spree 5.5 ships alongside `@spree/sdk` 1.1. The backend upgrade never touches your frontend source — bump the SDK in every JavaScript consumer of the Store API and take it through your normal PR/CI cycle:
117
+
118
+ ```bash
119
+ # create-spree-app projects: the Next.js storefront
120
+ cd apps/storefront
121
+ npm install @spree/sdk@^1.1
122
+ ```
123
+
124
+ If you maintain a separate storefront repo or other integrations, repeat there. The `spree upgrade` command detects the conventional `apps/storefront` and reminds you with the currently-declared version in its "Next steps" panel.
125
+
126
+ | Spree backend | `@spree/sdk` |
127
+ |---|---|
128
+ | 5.4 | 1.0.x |
129
+ | 5.5 | 1.1+ |
130
+
131
+ The SDK bump pairs with one storefront code change in this release: the [payment method `type` shorthand](#payment-method-type-on-the-wire-is-now-a-shorthand-not-a-rails-class-name) — update your gateway map when you bump.
132
+
133
+ ## Required post-upgrade configuration
134
+
135
+ `bin/rake spree:upgrade` doesn't touch your job-runner config — every app uses a different scheduler, so this one is on you.
136
+
76
137
  ### Schedule the Stock Reservations expiry job
77
138
 
78
139
  Spree 5.5 introduces time-limited stock reservations during checkout to prevent two customers from buying the same last unit at the same time. Abandoned checkouts leave behind expired reservation rows, and Spree does **not** auto-schedule the cleanup — your application's job runner must run `Spree::StockReservations::ExpireJob` periodically (every minute is the recommended cadence).
@@ -112,7 +173,11 @@ Rails.application.configure do
112
173
  end
113
174
  ```
114
175
 
115
- ### (Optional) Tune the reservation TTL
176
+ ## Optional tuning
177
+
178
+ Defaults are sensible for most stores. Reach for these only if you have a specific reason.
179
+
180
+ ### Tune the reservation TTL
116
181
 
117
182
  The default reservation TTL is **10 minutes**. To override globally:
118
183
 
@@ -129,7 +194,7 @@ store.update!(preferred_stock_reservation_ttl_minutes: 20)
129
194
 
130
195
  The per-Store value, when set, takes precedence over the global default.
131
196
 
132
- ### (Optional) Disable Stock Reservations
197
+ ### Disable Stock Reservations
133
198
 
134
199
  Stock reservations are enabled by default. To opt out and revert to pre-5.5 behavior (no holds during checkout, Quantifier returns raw `count_on_hand`):
135
200
 
@@ -140,7 +205,7 @@ Spree::Config[:stock_reservations_enabled] = false
140
205
 
141
206
  The Quantifier short-circuits before any reservation query when this is `false`, so there's no runtime cost and no table growth.
142
207
 
143
- ### (Optional) Opt out of rules-based Order Routing
208
+ ### Opt out of rules-based Order Routing
144
209
 
145
210
  Spree 5.5 introduces [Order Routing](../core-concepts/shipments.md#order-routing) — a configurable, per-channel pipeline that decides which stock locations fulfill an order. Every store and every channel ships with three default rules (Preferred Location → Minimize Splits → Default Location) that produce sensible behavior out of the box, with no migration work required.
146
211
 
@@ -154,7 +219,9 @@ The Legacy strategy delegates to `Spree::Stock::Coordinator`, which is the exact
154
219
 
155
220
  > **WARNING:** `Spree::OrderRouting::Strategy::Legacy` and `Spree::Stock::Coordinator` are slated for removal in Spree 6.0. Use this only as a temporary escape hatch while you evaluate the new Rules strategy. New 5.5+ installations should stay on the default Rules strategy.
156
221
 
157
- ## Behavior changes worth knowing
222
+ ## Behavior changes to review
223
+
224
+ These don't require any rake task — but storefronts, integrations, and merchant-facing dashboards may need code changes to handle them correctly.
158
225
 
159
226
  ### Cart changes during checkout can now fail with insufficient stock
160
227
 
@@ -207,4 +274,4 @@ The default routing strategy (`Spree::OrderRouting::Strategy::Rules`) packs the
207
274
 
208
275
  For most stores this is invisible: when one location can fulfill the entire cart, that location now wins consistently (instead of depending on database iteration order). When the cart needs to split across locations, the same multi-location split happens — just with the location order driven by rules.
209
276
 
210
- If you rely on the legacy "every location packed in iteration order, no rule consulted" behavior, see [Opt out of rules-based Order Routing](#optional-opt-out-of-rules-based-order-routing) above.
277
+ If you rely on the legacy "every location packed in iteration order, no rule consulted" behavior, see [Opt out of rules-based Order Routing](#opt-out-of-rules-based-order-routing) above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",