Class: Spree::Promotion::Rules::Channel
Instance Method Summary
collapse
#actionable?, additional_permitted_attributes, #eligibility_errors, for, human_description, #human_description, human_name, #human_name, #key
Instance Method Details
#applicable?(promotable) ⇒ Boolean
17
18
19
|
# File 'app/models/spree/promotion/rules/channel.rb', line 17
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
|
#channels ⇒ Object
21
22
23
24
25
|
# File 'app/models/spree/promotion/rules/channel.rb', line 21
def channels
return Spree::Channel.none if preferred_channel_ids.blank?
promotion.store.channels.where(id: preferred_channel_ids)
end
|
#eligible?(order, _options = {}) ⇒ Boolean
27
28
29
30
31
32
33
|
# File 'app/models/spree/promotion/rules/channel.rb', line 27
def eligible?(order, _options = {})
return false if preferred_channel_ids.empty?
return true if preferred_channel_ids.map(&:to_s).include?(order.channel_id.to_s)
eligibility_errors.add(:base, eligibility_error_message(:no_matching_channel))
false
end
|