Class: Spree::DeliveryMethodRules::ItemTotalRule

Inherits:
Spree::DeliveryMethodRule show all
Defined in:
app/models/spree/delivery_method_rules/item_total_rule.rb

Overview

Bounds the method by the package's item total (inclusive min/max in the owner's currency). Empty preferences pass — half-configured rules fail open per-rule, matching the PromotionRule/PriceRule convention.

Instance Method Summary collapse

Methods included from TypeLabels

#human_description, #human_name

Methods included from PreferenceSchema

#serialized_preferences

Instance Method Details

#eligible?(package) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'app/models/spree/delivery_method_rules/item_total_rule.rb', line 10

def eligible?(package)
  total = package.item_total
  return false if preferred_minimum_amount.present? && total < preferred_minimum_amount
  return false if preferred_maximum_amount.present? && total > preferred_maximum_amount

  true
end