Class: Spree::OrderRouting::Strategy::Rules
- Defined in:
- app/models/spree/order_routing/strategy/rules.rb
Overview
Default order routing strategy: walks Spree::OrderRoutingRule rows in priority order, runs the Reducer to fully rank eligible locations, packs each location, and lets Spree::Stock::Prioritizer distribute inventory units across packages so units that the top-ranked location can’t cover spill over to subsequent locations.
See docs/plans/6.0-order-routing.md.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #for_allocation ⇒ Object
- #for_cancellation ⇒ Object
- #for_release ⇒ Object
-
#for_sale(fulfillment:) ⇒ Object
Stock decrement / restock today happens via Spree::Shipment’s state machine (after_ship / after_cancel).
Methods inherited from Base
Constructor Details
This class inherits a constructor from Spree::OrderRouting::Strategy::Base
Instance Method Details
#for_allocation ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/spree/order_routing/strategy/rules.rb', line 12 def for_allocation locations = eligible_locations return [] if locations.empty? ordered = Reducer.new(applicable_rules.to_a, order: order).rank_all(locations) return [] if ordered.empty? packages = build_packages(ordered) packages = prioritize_packages(packages) estimate_rates(packages) end |
#for_cancellation ⇒ Object
32 |
# File 'app/models/spree/order_routing/strategy/rules.rb', line 32 def for_cancellation; end |
#for_release ⇒ Object
31 |
# File 'app/models/spree/order_routing/strategy/rules.rb', line 31 def for_release; end |
#for_sale(fulfillment:) ⇒ Object
Stock decrement / restock today happens via Spree::Shipment’s state machine (after_ship / after_cancel). The strategy methods below are part of the contract for the future reservation + typed-movement phase — see 6.0-stock-reservations.md and 6.0-typed-stock-movements.md. In 5.5 they are no-ops; the existing model callbacks already do the right thing.
30 |
# File 'app/models/spree/order_routing/strategy/rules.rb', line 30 def for_sale(fulfillment:); end |