Class: Spree::Promotion::Rules::AffiliatedPromotionRule

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

Instance Method Summary collapse

Instance Method Details

#affiliate_ids_stringObject



19
20
21
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 19

def affiliate_ids_string
  affiliate_ids.join(',')
end

#affiliate_ids_string=(s) ⇒ Object



23
24
25
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 23

def affiliate_ids_string=(s)
  self.affiliate_ids = s.to_s.split(',').map(&:strip)
end

#affiliate_listObject



27
28
29
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 27

def affiliate_list
  affiliate_ids
end

#affiliate_list=(a) ⇒ Object



31
32
33
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 31

def affiliate_list=(a)
  self.affiliate_ids = a
end

#applicable?(promotable) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 15

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

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

Returns:

  • (Boolean)


10
11
12
13
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 10

def eligible?(order, options = {})
  return true if order.user and order.user.affiliate? and affiliates.collect(&:id).include?(order.user.affiliate.id)
  false
end