Class: Spree::OrderRouting::Rules::PreferredLocation
- Inherits:
-
Spree::OrderRoutingRule
- Object
- Spree::OrderRoutingRule
- Spree::OrderRouting::Rules::PreferredLocation
- Defined in:
- app/models/spree/order_routing/rules/preferred_location.rb
Overview
Ranks the order’s inferred preferred location at 0 and abstains for everything else. Lets admins / staff / B2B contexts pin “fulfill from this location” without preventing fallback when the preferred location doesn’t actually stock the items — subsequent rules tie-break.
Instance Method Summary collapse
Instance Method Details
#rank(order, locations) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/spree/order_routing/rules/preferred_location.rb', line 9 def rank(order, locations) preferred_id = order.inferred_preferred_stock_location_id locations.map do |loc| LocationRanking.new( location: loc, rank: (preferred_id.present? && loc.id.to_s == preferred_id.to_s) ? 0 : nil ) end end |