spree_promo 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/checkout_controller_decorator.rb +7 -4
- data/app/controllers/spree/orders_controller_decorator.rb +2 -1
- data/app/models/spree/order_decorator.rb +1 -1
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -2
- data/lib/spree/promo/engine.rb +9 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2bcb36b3161c9cc5feb74608068d31d53651d0
|
4
|
+
data.tar.gz: 7cd89e77ada75630528557cc8a61aedd8adce059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0892f38c4782cb2312fe23d117ac7f763984919c250449d965754cab146166475abd73a7436e58e8ee830596f9055e1c65c0018efa060b976455b401c6475ef4
|
7
|
+
data.tar.gz: 1c1acc85af0985b74a14236917920925e589ed8f6332de2fb5c4b54033a02eaac03dff5e17c053e8528ce6dda81f5246491f10e3ff4a0245a4c3d373d6cd8f0f
|
@@ -2,13 +2,16 @@ Spree::CheckoutController.class_eval do
|
|
2
2
|
|
3
3
|
#TODO 90% of this method is duplicated code. DRY
|
4
4
|
def update
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
unless apply_coupon_code
|
5
|
+
if params[:order] && params[:order][:coupon_code]
|
6
|
+
@order.coupon_code = params[:order][:coupon_code]
|
7
|
+
unless status = apply_coupon_code
|
9
8
|
respond_with(@order) { |format| format.html { render :edit } }
|
10
9
|
return
|
11
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
if @order.update_attributes(object_params)
|
14
|
+
fire_event('spree.checkout.update')
|
12
15
|
|
13
16
|
if @order.next
|
14
17
|
state_callback(:after)
|
@@ -9,8 +9,9 @@ Spree::OrdersController.class_eval do
|
|
9
9
|
|
10
10
|
if @order.update_attributes(params[:order])
|
11
11
|
render :edit and return unless apply_coupon_code
|
12
|
-
|
12
|
+
|
13
13
|
@order.line_items = @order.line_items.select {|li| li.quantity > 0 }
|
14
|
+
@order.restart_checkout_flow
|
14
15
|
fire_event('spree.order.contents_changed')
|
15
16
|
respond_with(@order) do |format|
|
16
17
|
format.html do
|
@@ -27,7 +27,7 @@ Spree::Order.class_eval do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def find_promo_for_coupon_code
|
30
|
-
Spree::Promotion.where("LOWER(code) =
|
30
|
+
Spree::Promotion.where("LOWER(code) = ?", normalized_coupon_code).first
|
31
31
|
end
|
32
32
|
|
33
33
|
def normalized_coupon_code
|
@@ -57,8 +57,10 @@ module Spree
|
|
57
57
|
def deals_with_adjustments
|
58
58
|
self.adjustments.each do |adjustment|
|
59
59
|
if adjustment.adjustable.complete?
|
60
|
-
adjustment.
|
61
|
-
|
60
|
+
adjustment.update_attributes_without_callbacks(
|
61
|
+
:originator_id => nil,
|
62
|
+
:originator_type => nil
|
63
|
+
)
|
62
64
|
else
|
63
65
|
adjustment.destroy
|
64
66
|
end
|
data/lib/spree/promo/engine.rb
CHANGED
@@ -20,9 +20,12 @@ module Spree
|
|
20
20
|
config.autoload_paths += %W(#{config.root}/lib)
|
21
21
|
config.to_prepare &method(:activate).to_proc
|
22
22
|
|
23
|
+
# We need to define promotions rules here so extensions and existing apps
|
24
|
+
# can add their custom classes on their initializer files
|
23
25
|
initializer 'spree.promo.environment', :after => 'spree.environment' do |app|
|
24
26
|
app.config.spree.add_class('promotions')
|
25
27
|
app.config.spree.promotions = Spree::Promo::Environment.new
|
28
|
+
app.config.spree.promotions.rules = []
|
26
29
|
end
|
27
30
|
|
28
31
|
initializer 'spree.promo.register.promotion.calculators' do |app|
|
@@ -37,8 +40,12 @@ module Spree
|
|
37
40
|
]
|
38
41
|
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
# Promotion rules need to be evaluated on after initialize otherwise
|
44
|
+
# Spree.user_class would be nil and users might experience errors related
|
45
|
+
# to malformed model associations (Spree.user_class is only defined on
|
46
|
+
# the app initializer)
|
47
|
+
config.after_initialize do
|
48
|
+
Rails.application.config.spree.promotions.rules.concat [
|
42
49
|
Spree::Promotion::Rules::ItemTotal,
|
43
50
|
Spree::Promotion::Rules::Product,
|
44
51
|
Spree::Promotion::Rules::User,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_promo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David North
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.3.
|
19
|
+
version: 1.3.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3.
|
26
|
+
version: 1.3.5
|
27
27
|
description: Required dependency for Spree
|
28
28
|
email: david@spreecommerce.com
|
29
29
|
executables: []
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- app/models/spree/order_updater_decorator.rb
|
54
54
|
- app/models/spree/payment_decorator.rb
|
55
55
|
- app/models/spree/product_decorator.rb
|
56
|
+
- app/models/spree/promotion.rb
|
56
57
|
- app/models/spree/promotion/actions/create_adjustment.rb
|
57
58
|
- app/models/spree/promotion/actions/create_line_items.rb
|
58
59
|
- app/models/spree/promotion/rules/first_order.rb
|
@@ -60,7 +61,6 @@ files:
|
|
60
61
|
- app/models/spree/promotion/rules/product.rb
|
61
62
|
- app/models/spree/promotion/rules/user.rb
|
62
63
|
- app/models/spree/promotion/rules/user_logged_in.rb
|
63
|
-
- app/models/spree/promotion.rb
|
64
64
|
- app/models/spree/promotion_action.rb
|
65
65
|
- app/models/spree/promotion_action_line_item.rb
|
66
66
|
- app/models/spree/promotion_rule.rb
|
@@ -94,11 +94,11 @@ files:
|
|
94
94
|
- app/views/spree/products/_promotions.html.erb
|
95
95
|
- config/locales/en.yml
|
96
96
|
- config/routes.rb
|
97
|
+
- db/migrate/20120831092359_spree_promo_one_two.rb
|
98
|
+
- lib/spree/promo.rb
|
97
99
|
- lib/spree/promo/engine.rb
|
98
100
|
- lib/spree/promo/environment.rb
|
99
|
-
- lib/spree/promo.rb
|
100
101
|
- lib/spree_promo.rb
|
101
|
-
- db/migrate/20120831092359_spree_promo_one_two.rb
|
102
102
|
homepage: http://spreecommerce.com
|
103
103
|
licenses:
|
104
104
|
- BSD-3
|
@@ -109,18 +109,18 @@ require_paths:
|
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 1.8.7
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements:
|
121
121
|
- none
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.2.0
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Promotion functionality for use with Spree.
|