Class: Spree::OrderRoutingRule

Inherits:
Object
  • Object
show all
Includes:
SingleStoreResource
Defined in:
app/models/spree/order_routing_rule.rb

Overview

STI base for order routing rules. Subclasses live in app/models/spree/order_routing/rules/ and implement #rank(order, locations).

Plugins extend the engine by defining a new subclass:

class AcmeFresh::OrderRouting::RefrigeratedRule < Spree::OrderRoutingRule
  preference :max_temp_c, :integer, default: 4

  def rank(order, locations)
    # ... return Array<LocationRanking>
  end
end

See docs/plans/6.0-order-routing.md.

Defined Under Namespace

Classes: LocationRanking

Instance Method Summary collapse

Instance Method Details

#rank(_order, _locations) ⇒ Array<LocationRanking>

Subclasses override. Returns an Array<LocationRanking> — one per location, with rank=nil to abstain.

Parameters:

Returns:

Raises:

  • (NotImplementedError)


52
53
54
# File 'app/models/spree/order_routing_rule.rb', line 52

def rank(_order, _locations)
  raise NotImplementedError, "#{self.class} must implement #rank(order, locations)"
end