@spree/docs 0.1.143 → 0.1.145
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.
|
@@ -249,6 +249,8 @@ is reported through `Rails.error` so it's visible rather than mysterious.
|
|
|
249
249
|
| `payments.refund` | `before_refund` | lifecycle | Immediately before the gateway call |
|
|
250
250
|
| `payments.refund` | `after_refund` | lifecycle | After a successful refund |
|
|
251
251
|
| `payments.handle_webhook` | `after_handle` | lifecycle | After the gateway callback is processed |
|
|
252
|
+
| `customers.create` | `validate` | validate | After the customer is built, before it is saved — the registration-policy veto (bot screening, B2B approval) |
|
|
253
|
+
| `customers.create` | `after_create` | lifecycle | After the customer is created and the newsletter subscriber linked |
|
|
252
254
|
|
|
253
255
|
`before_cancel` and `before_resume` accept `reject!` like a `validate` hook.
|
|
254
256
|
|
|
@@ -233,9 +233,6 @@ First register the class so it's selectable (this is the allowlist the model val
|
|
|
233
233
|
```ruby
|
|
234
234
|
# config/initializers/spree.rb
|
|
235
235
|
Spree.order_routing.strategies << 'Acme::Oms::Strategy'.constantize
|
|
236
|
-
|
|
237
|
-
# Optionally drop the legacy escape hatch:
|
|
238
|
-
# Spree.order_routing.strategies.delete(Spree::OrderRouting::Strategy::Legacy)
|
|
239
236
|
```
|
|
240
237
|
|
|
241
238
|
Then select it by class name string — set on `Spree::Store` (default) or `Spree::Channel` (override). Setting an unregistered class fails validation.
|
|
@@ -241,7 +241,7 @@ store.update!(preferred_order_routing_strategy: 'Spree::OrderRouting::Strategy::
|
|
|
241
241
|
|
|
242
242
|
The Legacy strategy delegates to `Spree::Stock::Coordinator`, which is the exact pre-5.5 packing pipeline — every active stock location is packed, the Prioritizer distributes inventory units across the resulting packages, and no merchant routing rules are consulted. Your existing customizations on `Coordinator`, `Packer`, `Prioritizer`, and the splitters keep working unchanged.
|
|
243
243
|
|
|
244
|
-
> **WARNING:** `Spree::OrderRouting::Strategy::Legacy`
|
|
244
|
+
> **WARNING:** `Spree::OrderRouting::Strategy::Legacy` **was removed in Spree 6.0**. It exists only on the 5.5/5.6 line, as a temporary escape hatch while you evaluate the Rules strategy. Stores still carrying this value fall back to the default Rules strategy on 6.0 (with a logged warning), so clear the preference before upgrading.
|
|
245
245
|
|
|
246
246
|
## Behavior changes to review
|
|
247
247
|
|
|
@@ -209,6 +209,73 @@ Removed keys (their classes no longer exist): `carts_validate_service` (completi
|
|
|
209
209
|
|
|
210
210
|
If you override a workflow seam, subclass the shipped workflow (or implement the same `perform` keyword contract) — workflow arguments are plain Ruby keywords, so a mismatch raises `ArgumentError` at call time, not silently.
|
|
211
211
|
|
|
212
|
+
## Removed in 6.0
|
|
213
|
+
|
|
214
|
+
These were deprecated in 5.x and are **gone now** — there is no bridge, so calls raise `NoMethodError`. Most were one-line delegations to a replacement that already exists.
|
|
215
|
+
|
|
216
|
+
| Removed | Use instead |
|
|
217
|
+
|---|---|
|
|
218
|
+
| `Product#default_image`, `#featured_image`, `#primary_image` | `#primary_media` |
|
|
219
|
+
| `Variant#default_image`, `#primary_image` | `#primary_media` |
|
|
220
|
+
| `Address#user_default_billing?`, `#user_default_shipping?` | `#is_default_billing?`, `#is_default_shipping?` |
|
|
221
|
+
| `OptionType#color?` | `#color_swatch?` |
|
|
222
|
+
| `Category#set_store` | `#ensure_store` |
|
|
223
|
+
| `Category.for_taxonomy` | `.for_store` |
|
|
224
|
+
| `Store#admin_users` | `#users` |
|
|
225
|
+
| `Store#supported_shipping_zones` | `#countries_with_shipping_coverage` |
|
|
226
|
+
| `Spree.searcher_class` | `Spree.search_provider` |
|
|
227
|
+
| `Spree.admin_user_class.spree_admin_created?` | `.spree_admin.exists?` |
|
|
228
|
+
| `BaseMailer#set_email_locale` | wrap the action body in `with_store_locale(store) { ... }` |
|
|
229
|
+
| `Asset#styles`, `ImageMethods#generate_url`, `#original_url` | Active Storage variants with `cdn_image_url` |
|
|
230
|
+
| `Spree::ImageMethods`, `Spree::NumberAsParam` (concerns) | deleted — `NumberAsParam` was already a no-op; prefixed IDs come from `Spree::PrefixedId` |
|
|
231
|
+
| `Product.with_option`, `.with`, `.in_name`, `.in_name_or_keywords`, `.in_name_or_description`, `.with_ids`, `.for_user` | `.with_option_value`, `.search`, `where(id: ids)` |
|
|
232
|
+
| `Product.add_search_scope` | plain `scope :name, -> { ... }` |
|
|
233
|
+
| `Spree::Image::Configuration::ActiveStorage` | deleted — an empty no-op module; all logic lives in `Spree::Asset` |
|
|
234
|
+
| `Spree::OrderRouting::Strategy::Legacy` | `Spree::OrderRouting::Strategy::Rules` (see below) |
|
|
235
|
+
|
|
236
|
+
### The Legacy order-routing strategy is gone
|
|
237
|
+
|
|
238
|
+
`Spree::OrderRouting::Strategy::Legacy` — the pre-5.5 escape hatch that delegated straight to `Spree::Stock::Coordinator` and consulted no routing rules — is removed and no longer registered in `Spree.order_routing.strategies`.
|
|
239
|
+
|
|
240
|
+
A store or channel still carrying `preferred_order_routing_strategy: 'Spree::OrderRouting::Strategy::Legacy'` **keeps working**: `Order#order_routing_strategy` ignores unregistered classes, logs a warning, and falls back to `Strategy::Rules`. Clear the stale preference to silence the warning — note that saving such a record now fails validation, since the value is no longer in the registry.
|
|
241
|
+
|
|
242
|
+
`Spree::Stock::Coordinator` itself stays — cart fulfillment building, exchanges, and claims still use it.
|
|
243
|
+
|
|
244
|
+
### `Store.default` no longer builds a store
|
|
245
|
+
|
|
246
|
+
`Spree::Store.default` returned an **unpersisted** `Store.new(default: true)` when no default store existed. It now returns `nil`.
|
|
247
|
+
|
|
248
|
+
This matters more than it looks: `Spree::Current.store` falls back to `Store.default`, and every `Spree::SingleStoreResource` model resolves its own `store` from `Spree::Current.store`. Without a default store, those records now fail validation with "Store can't be blank" instead of silently attaching to a throwaway store.
|
|
249
|
+
|
|
250
|
+
Make sure a default store exists before creating store-scoped records, and set `Spree::Current.store` in jobs, rake tasks, and tests that run outside a request.
|
|
251
|
+
|
|
252
|
+
### The `DefaultPrice` concern is gone — `price_in` / `set_price` is the interface
|
|
253
|
+
|
|
254
|
+
`Spree::DefaultPrice` and the `enable_legacy_default_price` setting are removed, along with the `has_one :default_price` association on `Variant`. Prices live in `spree_prices`, one row per currency, and a price is always an **amount plus a currency** — there is no longer an implicit "the" price.
|
|
255
|
+
|
|
256
|
+
The single-currency accessors are gone from both `Variant` and `Product`:
|
|
257
|
+
|
|
258
|
+
| Removed | Use instead |
|
|
259
|
+
|---|---|
|
|
260
|
+
| `variant.price`, `product.price` | `variant.price_in(currency).amount` or `amount_in(currency)` |
|
|
261
|
+
| `variant.price = x`, `product.price = x` | `variant.set_price(currency, x)` |
|
|
262
|
+
| `variant.default_price` | `variant.price_in(currency)` |
|
|
263
|
+
| `variant.currency`, `product.currency` | the currency is an argument now — pass the one you mean |
|
|
264
|
+
| `display_price`, `display_amount` | `price_in(currency).display_amount` |
|
|
265
|
+
| `compare_at_price=` | `set_price(currency, amount, compare_at_amount)` |
|
|
266
|
+
| `display_compare_at_price` | `price_in(currency).display_compare_at_amount` |
|
|
267
|
+
| `price_including_vat_for(opts)` | `price_in(currency).price_including_vat_for(opts)` |
|
|
268
|
+
| `has_default_price?` | `prices.base_prices.exists?(currency: currency)` |
|
|
269
|
+
|
|
270
|
+
The `compare_at_price` **reader** (which resolves against `cost_currency`) is unchanged on both `Variant` and `Product` — only the writer is gone. So are the `price_in` / `amount_in` / `compare_at_amount_in` readers.
|
|
271
|
+
|
|
272
|
+
Also note:
|
|
273
|
+
|
|
274
|
+
- **Ransack:** `default_price` is no longer a searchable association on `Variant`; query `prices` instead.
|
|
275
|
+
- **`Spree::PermittedAttributes`:** the dead `:price` and `:compare_at_price` entries are dropped from `product_attributes` and `variant_attributes`. Prices were already written as nested `prices: [{ amount:, currency: }]` under variants — the top-level keys had no writer behind them.
|
|
276
|
+
- Localized number parsing still happens: `Spree::Price#amount=` runs `Spree::LocalizedNumber.parse`, so `set_price(currency, '1,599.99')` works as `price=` did.
|
|
277
|
+
- The variant validation that inferred a missing price from the product's default variant is gone. Set prices explicitly (the product and variant factories already do).
|
|
278
|
+
|
|
212
279
|
## Deprecated in 6.0, removed in 6.1
|
|
213
280
|
|
|
214
281
|
Every rename keeps the legacy name working for one release with a deprecation warning. The notable ones:
|