Class: Spree::Promotion::Rules::Currency

Inherits:
Spree::PromotionRule show all
Defined in:
app/models/spree/promotion/rules/currency.rb

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for, #human_description, #human_name, #key

Instance Method Details

#applicable?(promotable) ⇒ Boolean



8
9
10
# File 'app/models/spree/promotion/rules/currency.rb', line 8

def applicable?(promotable)
  promotable.is_a?(Spree::Order)
end

#eligible?(order, options = {}) ⇒ Boolean



12
13
14
15
16
17
# File 'app/models/spree/promotion/rules/currency.rb', line 12

def eligible?(order, options = {})
  return true if order.currency == preferred_currency

  eligibility_errors.add(:base, eligibility_error_message(:wrong_currency))
  false
end