Class: SpreeCmCommissioner::Promotion::Rules::GuestOccupations
- Inherits:
-
Guest
- Object
- Spree::PromotionRule
- Guest
- SpreeCmCommissioner::Promotion::Rules::GuestOccupations
show all
- Defined in:
- app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb
Constant Summary
Constants inherited
from Guest
SpreeCmCommissioner::Promotion::Rules::Guest::MATCH_POLICIES
Instance Method Summary
collapse
Methods inherited from Guest
#actionable?, #applicable?, #match_policy_condition?
Instance Method Details
#eligible?(order, _options = {}) ⇒ Boolean
17
18
19
20
21
22
23
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 17
def eligible?(order, _options = {})
return true if eligible_guest_occupations.empty?
order.line_items.any? do |line_item|
match_policy_condition?(line_item)
end
end
|
#eligible_guest_occupations ⇒ Object
12
13
14
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 12
def eligible_guest_occupations
guest_occupations
end
|
#guest_eligible?(guest, line_item) ⇒ Boolean
26
27
28
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 26
def guest_eligible?(guest, line_item)
eligible_guest_occupations.include?(guest.occupation) && line_item.product.kyc?
end
|
#guest_occupation_ids_string ⇒ Object
30
31
32
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 30
def guest_occupation_ids_string
guest_occupation_ids.join(',')
end
|
#guest_occupation_ids_string=(value) ⇒ Object
34
35
36
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 34
def guest_occupation_ids_string=(value)
self.guest_occupation_ids = value
end
|