spree_promo 0.70.3 → 0.70.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
|
|
1
|
+
CheckoutController.class_eval do
|
2
|
+
before_filter :apply_pending_promotions
|
3
|
+
|
4
|
+
def apply_pending_promotions
|
5
|
+
# apply all promotions that may have been triggered before theorder had been created
|
6
|
+
if current_user
|
7
|
+
current_user.pending_promotions.each do |promotional|
|
8
|
+
promotional.promotion.activate(:order => @order, :user => current_user)
|
9
|
+
promotional.destroy
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/app/models/promotion.rb
CHANGED
@@ -12,7 +12,7 @@ class Promotion < Activator
|
|
12
12
|
alias_method field, "preferred_#{field}"
|
13
13
|
alias_method "#{field}=", "preferred_#{field}="
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
has_many :promotion_rules, :foreign_key => 'activator_id', :autosave => true, :dependent => :destroy
|
17
17
|
alias_method :rules, :promotion_rules
|
18
18
|
accepts_nested_attributes_for :promotion_rules
|
@@ -87,7 +87,7 @@ class Promotion < Activator
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def credits
|
90
|
-
Adjustment.where(:originator_id => actions.map(&:id))
|
90
|
+
Adjustment.where(:originator_type => 'Promotion', :originator_id => actions.map(&:id))
|
91
91
|
end
|
92
92
|
|
93
93
|
def credits_count
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreatePendingPromotions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :pending_promotions do |t|
|
4
|
+
t.references :user
|
5
|
+
t.references :promotion
|
6
|
+
end
|
7
|
+
|
8
|
+
add_index :pending_promotions, :user_id
|
9
|
+
add_index :pending_promotions, :promotion_id
|
10
|
+
end
|
11
|
+
end
|
data/lib/spree_promo.rb
CHANGED
@@ -54,5 +54,18 @@ module SpreePromo
|
|
54
54
|
Promotion::Actions::CreateLineItems]
|
55
55
|
end
|
56
56
|
|
57
|
+
config.after_initialize do
|
58
|
+
ActiveSupport::Notifications.subscribe('spree.user.signup') do |*args|
|
59
|
+
event_name, start_time, end_time, id, payload = args
|
60
|
+
|
61
|
+
# Used for storing promotions before order has been created
|
62
|
+
# Fixes #836
|
63
|
+
::Promotion.active.event_name_starts_with('spree.user.signup').each do |activator|
|
64
|
+
if activator.eligible?(nil, payload) && payload[:user]
|
65
|
+
payload[:user].promotions << activator
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_promo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 271
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 70
|
9
|
-
-
|
10
|
-
version: 0.70.
|
9
|
+
- 4
|
10
|
+
version: 0.70.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David North
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-03-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -23,12 +23,12 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
hash:
|
26
|
+
hash: 271
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 70
|
30
|
-
-
|
31
|
-
version: 0.70.
|
30
|
+
- 4
|
31
|
+
version: 0.70.4
|
32
32
|
requirement: *id001
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
@@ -39,12 +39,12 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - "="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 271
|
43
43
|
segments:
|
44
44
|
- 0
|
45
45
|
- 70
|
46
|
-
-
|
47
|
-
version: 0.70.
|
46
|
+
- 4
|
47
|
+
version: 0.70.4
|
48
48
|
requirement: *id002
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
@@ -68,11 +68,13 @@ files:
|
|
68
68
|
- app/controllers/admin/promotion_actions_controller.rb
|
69
69
|
- app/controllers/admin/promotion_rules_controller.rb
|
70
70
|
- app/controllers/admin/promotions_controller.rb
|
71
|
+
- app/controllers/checkout_controller_decorator.rb
|
71
72
|
- app/controllers/content_controller_decorator.rb
|
72
73
|
- app/controllers/orders_controller_decorator.rb
|
73
74
|
- app/models/adjustment_decorator.rb
|
74
75
|
- app/models/calculator/free_shipping.rb
|
75
76
|
- app/models/order_decorator.rb
|
77
|
+
- app/models/pending_promotion.rb
|
76
78
|
- app/models/product_decorator.rb
|
77
79
|
- app/models/product_group_decorator.rb
|
78
80
|
- app/models/promotion/actions/create_adjustment.rb
|
@@ -87,6 +89,7 @@ files:
|
|
87
89
|
- app/models/promotion_action.rb
|
88
90
|
- app/models/promotion_action_line_item.rb
|
89
91
|
- app/models/promotion_rule.rb
|
92
|
+
- app/models/user_decorator.rb
|
90
93
|
- app/overrides/promo_admin_tabs.rb
|
91
94
|
- app/overrides/promo_coupon_code_field.rb
|
92
95
|
- app/overrides/promo_product_properties.rb
|
@@ -131,6 +134,7 @@ files:
|
|
131
134
|
- db/migrate/20110331094351_promotion_changes_to_subclass_of_activator.rb
|
132
135
|
- db/migrate/20110404123358_create_promotion_actions.rb
|
133
136
|
- db/migrate/20110601202923_create_promotion_action_line_items.rb
|
137
|
+
- db/migrate/20120119024708_create_pending_promotions.rb
|
134
138
|
homepage: http://spreecommerce.com
|
135
139
|
licenses: []
|
136
140
|
|