@spree/docs 0.1.79 → 0.1.81
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.
|
@@ -88,7 +88,12 @@ Spree::OrderRouting::Rules::ClosestLocation.create!(
|
|
|
88
88
|
)
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Spree's autoloader picks up
|
|
91
|
+
Register the rule kind so it's available to add and passes the `type` validation. Spree's autoloader picks up the model under `app/models/`; the registry is the curated allowlist (it also drives admin pickers):
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
# config/initializers/spree.rb
|
|
95
|
+
Spree.order_routing.rules << 'AcmeFresh::OrderRouting::RefrigeratedRule'.constantize
|
|
96
|
+
```
|
|
92
97
|
|
|
93
98
|
To activate the rule across multiple channels, create one row per channel. That keeps each channel's rule list explicit and lets you tune per-channel preferences independently.
|
|
94
99
|
|
|
@@ -223,7 +228,17 @@ Notes:
|
|
|
223
228
|
|
|
224
229
|
### Step 2: Register the Strategy
|
|
225
230
|
|
|
226
|
-
|
|
231
|
+
First register the class so it's selectable (this is the allowlist the model validation checks against, and the source for admin strategy pickers):
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
# config/initializers/spree.rb
|
|
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
|
+
```
|
|
240
|
+
|
|
241
|
+
Then select it by class name string — set on `Spree::Store` (default) or `Spree::Channel` (override). Setting an unregistered class fails validation.
|
|
227
242
|
|
|
228
243
|
Activate on the whole store:
|
|
229
244
|
|
|
@@ -242,7 +257,7 @@ store.channels.find_by(code: 'pos').update!(
|
|
|
242
257
|
)
|
|
243
258
|
```
|
|
244
259
|
|
|
245
|
-
Resolution order: `channel.preferred_order_routing_strategy` → `store.preferred_order_routing_strategy
|
|
260
|
+
Resolution order: `channel.preferred_order_routing_strategy` → `store.preferred_order_routing_strategy` → the default `Strategy::Rules`. Only a value pointing to a **registered** `Strategy::Base` subclass is used; anything unset, unregistered, or invalid is skipped, so a misconfiguration (or a strategy you've since unregistered) falls back to the default instead of breaking checkout.
|
|
246
261
|
|
|
247
262
|
### Step 3: Test the Strategy
|
|
248
263
|
|