5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/shop/models/form_extension.rb', line 5
def self.included(base)
base.class_eval do
def find_current_order
@order = ShopOrder.find_by_session(@page.request.session[:shop_order])
end
def find_or_create_current_order
begin
@order = find_current_order
rescue
@order = ShopOrder.create
@result[:session] = { :shop_order => @order.id }
end
if current_user
@order.update_attribute(:customer_id, (current_user.id))
end
@order
end
end
end
|