5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/shop_discounts/models/shop_order.rb', line 5
def self.included(base)
base.class_eval do
def apply_customer_discounts
if customer.present?
customer.discounts.each do |discount|
ShopDiscountable.create(:discount_id => discount.id, :discounted_id => self.id, :discounted_type => self.class.name)
end
end
end
class << self
alias_method :original_find_by_session, :find_by_session
def find_by_session(session)
if order = original_find_by_session(session)
order.apply_customer_discounts
end
order
end
end
end
end
|