Class: Spree::OrderRoutingRule
- Inherits:
-
Object
- Object
- Spree::OrderRoutingRule
- Extended by:
- ClassMethods
- 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.
Direct Known Subclasses
Spree::OrderRouting::Rules::DefaultLocation, Spree::OrderRouting::Rules::MinimizeSplits, Spree::OrderRouting::Rules::PreferredLocation
Defined Under Namespace
Modules: ClassMethods Classes: LocationRanking
Class Method Summary collapse
-
.description ⇒ Object
Feeds the
descriptionfield ofsubclasses_with_preference_schema(the/typesdiscovery payload), which only reads.description. -
.human_description ⇒ String
Localized description for the rule kind.
-
.human_name ⇒ String
Localized display name for the rule kind, used by admin pickers.
Instance Method Summary collapse
- #human_description ⇒ Object
- #human_name ⇒ Object
-
#rank(_order, _locations) ⇒ Array<LocationRanking>
Subclasses override.
Class Method Details
.description ⇒ Object
Feeds the description field of subclasses_with_preference_schema
(the /types discovery payload), which only reads .description.
66 67 68 |
# File 'app/models/spree/order_routing_rule.rb', line 66 def self.description human_description end |
.human_description ⇒ String
Returns localized description for the rule kind.
60 61 62 |
# File 'app/models/spree/order_routing_rule.rb', line 60 def self.human_description Spree.t("order_routing_rule_types.#{api_type}.description", default: '') end |
.human_name ⇒ String
Returns localized display name for the rule kind, used by admin pickers.
55 56 57 |
# File 'app/models/spree/order_routing_rule.rb', line 55 def self.human_name Spree.t("order_routing_rule_types.#{api_type}.name", default: api_type.titleize) end |
Instance Method Details
#human_description ⇒ Object
71 |
# File 'app/models/spree/order_routing_rule.rb', line 71 def human_description = self.class.human_description |
#human_name ⇒ Object
70 |
# File 'app/models/spree/order_routing_rule.rb', line 70 def human_name = self.class.human_name |
#rank(_order, _locations) ⇒ Array<LocationRanking>
Subclasses override. Returns an Array
79 80 81 |
# File 'app/models/spree/order_routing_rule.rb', line 79 def rank(_order, _locations) raise NotImplementedError, "#{self.class} must implement #rank(order, locations)" end |