Class: Spree::Promotion::Rules::CustomerGroup
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
10
11
12
|
# File 'app/models/spree/promotion/rules/customer_group.rb', line 10
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
|
#customer_groups ⇒ Object
14
15
16
17
18
|
# File 'app/models/spree/promotion/rules/customer_group.rb', line 14
def customer_groups
return Spree::CustomerGroup.none if preferred_customer_group_ids.blank?
Spree::CustomerGroup.where(id: preferred_customer_group_ids)
end
|
#eligible?(order, _options = {}) ⇒ Boolean
20
21
22
23
24
25
26
27
|
# File 'app/models/spree/promotion/rules/customer_group.rb', line 20
def eligible?(order, _options = {})
return false unless order.user_id.present?
return false if preferred_customer_group_ids.empty?
user_customer_group_ids = Spree::CustomerGroupUser.where(user_id: order.user_id).pluck(:customer_group_id).map(&:to_s)
(preferred_customer_group_ids.map(&:to_s) & user_customer_group_ids).any?
end
|