solidus_frontend 1.2.3 → 1.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_frontend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Rakefile +1 -1
- data/app/assets/javascripts/spree/frontend/checkout/address.js.coffee +0 -2
- data/app/assets/stylesheets/spree/frontend.css +1 -2
- data/app/assets/stylesheets/spree/frontend/_skeleton.scss +242 -0
- data/app/assets/stylesheets/spree/frontend/screen.css.scss +1 -0
- data/app/controllers/spree/checkout_controller.rb +93 -93
- data/app/controllers/spree/content_controller.rb +1 -1
- data/app/controllers/spree/orders_controller.rb +15 -16
- data/app/controllers/spree/products_controller.rb +19 -18
- data/app/controllers/spree/store_controller.rb +27 -27
- data/app/controllers/spree/taxons_controller.rb +1 -2
- data/app/models/spree/frontend_configuration.rb +1 -1
- data/app/views/spree/address/_form.html.erb +18 -12
- data/app/views/spree/orders/show.html.erb +2 -2
- data/app/views/spree/products/_cart_form.html.erb +5 -5
- data/app/views/spree/products/show.html.erb +1 -1
- data/app/views/spree/shared/_google_analytics.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +12 -11
- data/app/views/spree/shared/_products.html.erb +2 -2
- data/config/initializers/assets.rb +8 -1
- data/config/initializers/canonical_rails.rb +1 -2
- data/config/routes.rb +17 -18
- data/lib/spree/frontend.rb +1 -0
- data/lib/spree/frontend/engine.rb +1 -9
- data/lib/spree/frontend/middleware/seo_assist.rb +3 -4
- data/lib/tasks/rake_util.rb +3 -6
- data/lib/tasks/taxon.rake +3 -3
- data/script/rails +0 -1
- data/solidus_frontend.gemspec +1 -0
- data/spec/controllers/controller_extension_spec.rb +15 -15
- data/spec/controllers/controller_helpers_spec.rb +1 -2
- data/spec/controllers/spree/checkout_controller_spec.rb +67 -115
- data/spec/controllers/spree/content_controller_spec.rb +1 -1
- data/spec/controllers/spree/current_order_tracking_spec.rb +7 -6
- data/spec/controllers/spree/home_controller_spec.rb +3 -3
- data/spec/controllers/spree/orders_controller_ability_spec.rb +17 -16
- data/spec/controllers/spree/orders_controller_spec.rb +9 -8
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +5 -5
- data/spec/controllers/spree/products_controller_spec.rb +10 -11
- data/spec/controllers/spree/taxons_controller_spec.rb +5 -5
- data/spec/features/address_spec.rb +15 -15
- data/spec/features/automatic_promotion_adjustments_spec.rb +18 -18
- data/spec/features/caching/products_spec.rb +2 -2
- data/spec/features/caching/taxons_spec.rb +2 -2
- data/spec/features/cart_spec.rb +8 -6
- data/spec/features/checkout_spec.rb +49 -51
- data/spec/features/checkout_unshippable_spec.rb +4 -5
- data/spec/features/coupon_code_spec.rb +28 -30
- data/spec/features/currency_spec.rb +3 -3
- data/spec/features/free_shipping_promotions_spec.rb +17 -17
- data/spec/features/locale_spec.rb +33 -24
- data/spec/features/order_spec.rb +4 -4
- data/spec/features/products_spec.rb +12 -12
- data/spec/features/promotion_code_invalidation_spec.rb +1 -0
- data/spec/features/quantity_promotions_spec.rb +1 -1
- data/spec/features/taxons_spec.rb +16 -16
- data/spec/features/template_rendering_spec.rb +1 -2
- data/spec/helpers/base_helper_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/support/shared_contexts/checkout_setup.rb +1 -0
- data/spec/support/shared_contexts/custom_products.rb +18 -17
- data/spec/support/shared_contexts/product_prototypes.rb +3 -5
- data/spec/views/spree/checkout/_summary_spec.rb +2 -2
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 557f1380ace494c533f71574c8e3c20d2ebcac9d
|
4
|
+
data.tar.gz: 4ad6870c05f6b1fd2cd8efa05010aff5be01b8ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f00ccf8be0e5d04a794867da361945679a1e0983cac928f998ed36354e5a41ca15dc3ed2ea6ebf71f7f6e4515ec9ac2229f52f86e01554a162a56ad1f05dd132
|
7
|
+
data.tar.gz: 0f6ad8ca6f6526e1525326ae87574d15352ad99aa7eb344a11fa5908db7b60b012626c381c4d66148af4cb4865467e48f38165617e2044d534edcc181d83f77f
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
eval_gemfile File.expand_path('../../common_spree_dependencies.rb', __FILE__)
|
2
2
|
|
3
|
-
gem 'solidus_core', :
|
4
|
-
gem 'solidus_api', :
|
3
|
+
gem 'solidus_core', path: '../core'
|
4
|
+
gem 'solidus_api', path: '../api'
|
5
5
|
|
6
6
|
gemspec
|
data/Rakefile
CHANGED
@@ -52,7 +52,6 @@ $ ->
|
|
52
52
|
else
|
53
53
|
stateSelect.removeClass('required')
|
54
54
|
stateSpanRequired.hide()
|
55
|
-
stateSelect.removeClass('hidden')
|
56
55
|
stateInput.removeClass('required')
|
57
56
|
else
|
58
57
|
stateSelect.hide().prop 'disabled', true
|
@@ -66,7 +65,6 @@ $ ->
|
|
66
65
|
stateInput.removeClass('required')
|
67
66
|
statePara.toggle(!!statesRequired)
|
68
67
|
stateInput.prop('disabled', !statesRequired)
|
69
|
-
stateInput.removeClass('hidden')
|
70
68
|
stateSelect.removeClass('required')
|
71
69
|
|
72
70
|
$('#bcountry select').change ->
|
@@ -0,0 +1,242 @@
|
|
1
|
+
/*
|
2
|
+
* Skeleton V1.2
|
3
|
+
* Copyright 2011, Dave Gamache
|
4
|
+
* www.getskeleton.com
|
5
|
+
* Free to use under the MIT license.
|
6
|
+
* http://www.opensource.org/licenses/mit-license.php
|
7
|
+
* 6/20/2012
|
8
|
+
*/
|
9
|
+
|
10
|
+
|
11
|
+
/* Table of Contents
|
12
|
+
==================================================
|
13
|
+
#Base 960 Grid
|
14
|
+
#Tablet (Portrait)
|
15
|
+
#Mobile (Portrait)
|
16
|
+
#Mobile (Landscape)
|
17
|
+
#Clearing */
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
/* #Base 960 Grid
|
22
|
+
================================================== */
|
23
|
+
|
24
|
+
.container { position: relative; width: 960px; margin: 0 auto; padding: 0; }
|
25
|
+
.container .column,
|
26
|
+
.container .columns { float: left; display: inline; margin-left: 10px; margin-right: 10px; }
|
27
|
+
.row { margin-bottom: 20px; }
|
28
|
+
|
29
|
+
/* Nested Column Classes */
|
30
|
+
.column.alpha, .columns.alpha { margin-left: 0; }
|
31
|
+
.column.omega, .columns.omega { margin-right: 0; }
|
32
|
+
|
33
|
+
/* Base Grid */
|
34
|
+
.container .one.column,
|
35
|
+
.container .one.columns { width: 40px; }
|
36
|
+
.container .two.columns { width: 100px; }
|
37
|
+
.container .three.columns { width: 160px; }
|
38
|
+
.container .four.columns { width: 220px; }
|
39
|
+
.container .five.columns { width: 280px; }
|
40
|
+
.container .six.columns { width: 340px; }
|
41
|
+
.container .seven.columns { width: 400px; }
|
42
|
+
.container .eight.columns { width: 460px; }
|
43
|
+
.container .nine.columns { width: 520px; }
|
44
|
+
.container .ten.columns { width: 580px; }
|
45
|
+
.container .eleven.columns { width: 640px; }
|
46
|
+
.container .twelve.columns { width: 700px; }
|
47
|
+
.container .thirteen.columns { width: 760px; }
|
48
|
+
.container .fourteen.columns { width: 820px; }
|
49
|
+
.container .fifteen.columns { width: 880px; }
|
50
|
+
.container .sixteen.columns { width: 940px; }
|
51
|
+
|
52
|
+
.container .one-third.column { width: 300px; }
|
53
|
+
.container .two-thirds.column { width: 620px; }
|
54
|
+
|
55
|
+
/* Offsets */
|
56
|
+
.container .offset-by-one { padding-left: 60px; }
|
57
|
+
.container .offset-by-two { padding-left: 120px; }
|
58
|
+
.container .offset-by-three { padding-left: 180px; }
|
59
|
+
.container .offset-by-four { padding-left: 240px; }
|
60
|
+
.container .offset-by-five { padding-left: 300px; }
|
61
|
+
.container .offset-by-six { padding-left: 360px; }
|
62
|
+
.container .offset-by-seven { padding-left: 420px; }
|
63
|
+
.container .offset-by-eight { padding-left: 480px; }
|
64
|
+
.container .offset-by-nine { padding-left: 540px; }
|
65
|
+
.container .offset-by-ten { padding-left: 600px; }
|
66
|
+
.container .offset-by-eleven { padding-left: 660px; }
|
67
|
+
.container .offset-by-twelve { padding-left: 720px; }
|
68
|
+
.container .offset-by-thirteen { padding-left: 780px; }
|
69
|
+
.container .offset-by-fourteen { padding-left: 840px; }
|
70
|
+
.container .offset-by-fifteen { padding-left: 900px; }
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
/* #Tablet (Portrait)
|
75
|
+
================================================== */
|
76
|
+
|
77
|
+
/* Note: Design for a width of 768px */
|
78
|
+
|
79
|
+
@media only screen and (min-width: 768px) and (max-width: 959px) {
|
80
|
+
.container { width: 768px; }
|
81
|
+
.container .column,
|
82
|
+
.container .columns { margin-left: 10px; margin-right: 10px; }
|
83
|
+
.column.alpha, .columns.alpha { margin-left: 0; margin-right: 10px; }
|
84
|
+
.column.omega, .columns.omega { margin-right: 0; margin-left: 10px; }
|
85
|
+
.alpha.omega { margin-left: 0; margin-right: 0; }
|
86
|
+
|
87
|
+
.container .one.column,
|
88
|
+
.container .one.columns { width: 28px; }
|
89
|
+
.container .two.columns { width: 76px; }
|
90
|
+
.container .three.columns { width: 124px; }
|
91
|
+
.container .four.columns { width: 172px; }
|
92
|
+
.container .five.columns { width: 220px; }
|
93
|
+
.container .six.columns { width: 268px; }
|
94
|
+
.container .seven.columns { width: 316px; }
|
95
|
+
.container .eight.columns { width: 364px; }
|
96
|
+
.container .nine.columns { width: 412px; }
|
97
|
+
.container .ten.columns { width: 460px; }
|
98
|
+
.container .eleven.columns { width: 508px; }
|
99
|
+
.container .twelve.columns { width: 556px; }
|
100
|
+
.container .thirteen.columns { width: 604px; }
|
101
|
+
.container .fourteen.columns { width: 652px; }
|
102
|
+
.container .fifteen.columns { width: 700px; }
|
103
|
+
.container .sixteen.columns { width: 748px; }
|
104
|
+
|
105
|
+
.container .one-third.column { width: 236px; }
|
106
|
+
.container .two-thirds.column { width: 492px; }
|
107
|
+
|
108
|
+
/* Offsets */
|
109
|
+
.container .offset-by-one { padding-left: 48px; }
|
110
|
+
.container .offset-by-two { padding-left: 96px; }
|
111
|
+
.container .offset-by-three { padding-left: 144px; }
|
112
|
+
.container .offset-by-four { padding-left: 192px; }
|
113
|
+
.container .offset-by-five { padding-left: 240px; }
|
114
|
+
.container .offset-by-six { padding-left: 288px; }
|
115
|
+
.container .offset-by-seven { padding-left: 336px; }
|
116
|
+
.container .offset-by-eight { padding-left: 384px; }
|
117
|
+
.container .offset-by-nine { padding-left: 432px; }
|
118
|
+
.container .offset-by-ten { padding-left: 480px; }
|
119
|
+
.container .offset-by-eleven { padding-left: 528px; }
|
120
|
+
.container .offset-by-twelve { padding-left: 576px; }
|
121
|
+
.container .offset-by-thirteen { padding-left: 624px; }
|
122
|
+
.container .offset-by-fourteen { padding-left: 672px; }
|
123
|
+
.container .offset-by-fifteen { padding-left: 720px; }
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
/* #Mobile (Portrait)
|
128
|
+
================================================== */
|
129
|
+
|
130
|
+
/* Note: Design for a width of 320px */
|
131
|
+
|
132
|
+
@media only screen and (max-width: 767px) {
|
133
|
+
.container { width: 300px; }
|
134
|
+
.container .columns,
|
135
|
+
.container .column { margin: 0; }
|
136
|
+
|
137
|
+
.container .one.column,
|
138
|
+
.container .one.columns,
|
139
|
+
.container .two.columns,
|
140
|
+
.container .three.columns,
|
141
|
+
.container .four.columns,
|
142
|
+
.container .five.columns,
|
143
|
+
.container .six.columns,
|
144
|
+
.container .seven.columns,
|
145
|
+
.container .eight.columns,
|
146
|
+
.container .nine.columns,
|
147
|
+
.container .ten.columns,
|
148
|
+
.container .eleven.columns,
|
149
|
+
.container .twelve.columns,
|
150
|
+
.container .thirteen.columns,
|
151
|
+
.container .fourteen.columns,
|
152
|
+
.container .fifteen.columns,
|
153
|
+
.container .sixteen.columns,
|
154
|
+
.container .one-third.column,
|
155
|
+
.container .two-thirds.column { width: 300px; }
|
156
|
+
|
157
|
+
/* Offsets */
|
158
|
+
.container .offset-by-one,
|
159
|
+
.container .offset-by-two,
|
160
|
+
.container .offset-by-three,
|
161
|
+
.container .offset-by-four,
|
162
|
+
.container .offset-by-five,
|
163
|
+
.container .offset-by-six,
|
164
|
+
.container .offset-by-seven,
|
165
|
+
.container .offset-by-eight,
|
166
|
+
.container .offset-by-nine,
|
167
|
+
.container .offset-by-ten,
|
168
|
+
.container .offset-by-eleven,
|
169
|
+
.container .offset-by-twelve,
|
170
|
+
.container .offset-by-thirteen,
|
171
|
+
.container .offset-by-fourteen,
|
172
|
+
.container .offset-by-fifteen { padding-left: 0; }
|
173
|
+
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
/* #Mobile (Landscape)
|
178
|
+
================================================== */
|
179
|
+
|
180
|
+
/* Note: Design for a width of 480px */
|
181
|
+
|
182
|
+
@media only screen and (min-width: 480px) and (max-width: 767px) {
|
183
|
+
.container { width: 420px; }
|
184
|
+
.container .columns,
|
185
|
+
.container .column { margin: 0; }
|
186
|
+
|
187
|
+
.container .one.column,
|
188
|
+
.container .one.columns,
|
189
|
+
.container .two.columns,
|
190
|
+
.container .three.columns,
|
191
|
+
.container .four.columns,
|
192
|
+
.container .five.columns,
|
193
|
+
.container .six.columns,
|
194
|
+
.container .seven.columns,
|
195
|
+
.container .eight.columns,
|
196
|
+
.container .nine.columns,
|
197
|
+
.container .ten.columns,
|
198
|
+
.container .eleven.columns,
|
199
|
+
.container .twelve.columns,
|
200
|
+
.container .thirteen.columns,
|
201
|
+
.container .fourteen.columns,
|
202
|
+
.container .fifteen.columns,
|
203
|
+
.container .sixteen.columns,
|
204
|
+
.container .one-third.column,
|
205
|
+
.container .two-thirds.column { width: 420px; }
|
206
|
+
}
|
207
|
+
|
208
|
+
|
209
|
+
/* #Clearing
|
210
|
+
================================================== */
|
211
|
+
|
212
|
+
/* Self Clearing Goodness */
|
213
|
+
.container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; }
|
214
|
+
|
215
|
+
/* Use clearfix class on parent to clear nested columns,
|
216
|
+
or wrap each row of columns in a <div class="row"> */
|
217
|
+
.clearfix:before,
|
218
|
+
.clearfix:after,
|
219
|
+
.row:before,
|
220
|
+
.row:after {
|
221
|
+
content: '\0020';
|
222
|
+
display: block;
|
223
|
+
overflow: hidden;
|
224
|
+
visibility: hidden;
|
225
|
+
width: 0;
|
226
|
+
height: 0; }
|
227
|
+
.row:after,
|
228
|
+
.clearfix:after {
|
229
|
+
clear: both; }
|
230
|
+
.row,
|
231
|
+
.clearfix {
|
232
|
+
zoom: 1; }
|
233
|
+
|
234
|
+
/* You can also use a <br class="clear" /> to clear columns */
|
235
|
+
.clear {
|
236
|
+
clear: both;
|
237
|
+
display: block;
|
238
|
+
overflow: hidden;
|
239
|
+
visibility: hidden;
|
240
|
+
width: 0;
|
241
|
+
height: 0;
|
242
|
+
}
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
# This is somewhat contrary to standard REST convention since there is not
|
3
3
|
# actually a Checkout object. There's enough distinct logic specific to
|
4
4
|
# checkout which has nothing to do with updating an order that this approach
|
5
|
-
# is
|
5
|
+
# is warranted.
|
6
6
|
class CheckoutController < Spree::StoreController
|
7
7
|
before_filter :load_order
|
8
8
|
around_filter :lock_order
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
|
22
22
|
helper 'spree/orders'
|
23
23
|
|
24
|
-
rescue_from Spree::Core::GatewayError, :
|
24
|
+
rescue_from Spree::Core::GatewayError, with: :rescue_from_spree_gateway_error
|
25
25
|
|
26
26
|
# Updates the order and advances to the next state (when possible.)
|
27
27
|
def update
|
@@ -34,7 +34,7 @@ module Spree
|
|
34
34
|
end
|
35
35
|
if !success
|
36
36
|
flash[:error] = @order.errors.full_messages.join("\n")
|
37
|
-
redirect_to
|
37
|
+
redirect_to(checkout_state_path(@order.state)) && return
|
38
38
|
end
|
39
39
|
|
40
40
|
if @order.completed?
|
@@ -52,124 +52,124 @@ module Spree
|
|
52
52
|
|
53
53
|
private
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
55
|
+
def update_params
|
56
|
+
if update_params = massaged_params[:order]
|
57
|
+
update_params.permit(permitted_checkout_attributes)
|
58
|
+
else
|
59
|
+
# We current allow update requests without any parameters in them.
|
60
|
+
{}
|
62
61
|
end
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
move_payment_source_into_payments_attributes(massaged_params)
|
68
|
-
move_existing_card_into_payments_attributes(massaged_params)
|
69
|
-
set_payment_parameters_amount(massaged_params, @order)
|
64
|
+
def massaged_params
|
65
|
+
massaged_params = params.deep_dup
|
70
66
|
|
71
|
-
|
72
|
-
|
67
|
+
move_payment_source_into_payments_attributes(massaged_params)
|
68
|
+
move_existing_card_into_payments_attributes(massaged_params)
|
69
|
+
set_payment_parameters_amount(massaged_params, @order)
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
if (params[:state] && !@order.has_checkout_step?(params[:state])) ||
|
77
|
-
(!params[:state] && !@order.has_checkout_step?(@order.state))
|
78
|
-
@order.state = 'cart'
|
79
|
-
redirect_to checkout_state_path(@order.checkout_steps.first)
|
80
|
-
end
|
81
|
-
end
|
71
|
+
massaged_params
|
72
|
+
end
|
82
73
|
|
83
|
-
|
84
|
-
|
85
|
-
if params[:state]
|
86
|
-
|
87
|
-
|
74
|
+
def ensure_valid_state
|
75
|
+
unless skip_state_validation?
|
76
|
+
if (params[:state] && !@order.has_checkout_step?(params[:state])) ||
|
77
|
+
(!params[:state] && !@order.has_checkout_step?(@order.state))
|
78
|
+
@order.state = 'cart'
|
79
|
+
redirect_to checkout_state_path(@order.checkout_steps.first)
|
88
80
|
end
|
89
81
|
end
|
90
82
|
|
91
|
-
#
|
92
|
-
#
|
93
|
-
|
94
|
-
|
83
|
+
# Fix for https://github.com/spree/spree/issues/4117
|
84
|
+
# If confirmation of payment fails, redirect back to payment screen
|
85
|
+
if params[:state] == "confirm" && @order.payment_required? && @order.payments.valid.empty?
|
86
|
+
flash.keep
|
87
|
+
redirect_to checkout_state_path("payment")
|
95
88
|
end
|
89
|
+
end
|
96
90
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
# Should be overriden if you have areas of your checkout that don't match
|
92
|
+
# up to a step within checkout_steps, such as a registration step
|
93
|
+
def skip_state_validation?
|
94
|
+
false
|
95
|
+
end
|
101
96
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
97
|
+
def load_order
|
98
|
+
@order = current_order
|
99
|
+
redirect_to(spree.cart_path) && return unless @order
|
100
|
+
end
|
108
101
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
102
|
+
def set_state_if_present
|
103
|
+
if params[:state]
|
104
|
+
redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
|
105
|
+
@order.state = params[:state]
|
113
106
|
end
|
107
|
+
end
|
114
108
|
|
115
|
-
|
116
|
-
|
109
|
+
def ensure_checkout_allowed
|
110
|
+
unless @order.checkout_allowed?
|
111
|
+
redirect_to spree.cart_path
|
117
112
|
end
|
113
|
+
end
|
118
114
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
redirect_to spree.cart_path
|
123
|
-
end
|
124
|
-
end
|
115
|
+
def ensure_order_not_completed
|
116
|
+
redirect_to spree.cart_path if @order.completed?
|
117
|
+
end
|
125
118
|
|
126
|
-
|
127
|
-
|
128
|
-
|
119
|
+
def ensure_sufficient_stock_lines
|
120
|
+
if @order.insufficient_stock_lines.present?
|
121
|
+
flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
|
122
|
+
redirect_to spree.cart_path
|
129
123
|
end
|
124
|
+
end
|
130
125
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
126
|
+
# Provides a route to redirect after order completion
|
127
|
+
def completion_route
|
128
|
+
spree.order_path(@order)
|
129
|
+
end
|
135
130
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
@order.build_bill_address(default) unless @order.bill_address
|
141
|
-
@order.build_ship_address(default) if @order.checkout_steps.include?('delivery') && !@order.ship_address
|
142
|
-
end
|
131
|
+
def setup_for_current_state
|
132
|
+
method_name = :"before_#{@order.state}"
|
133
|
+
send(method_name) if respond_to?(method_name, true)
|
134
|
+
end
|
143
135
|
|
144
|
-
|
145
|
-
|
136
|
+
def before_address
|
137
|
+
# if the user has a default address, a callback takes care of setting
|
138
|
+
# that; but if he doesn't, we need to build an empty one here
|
139
|
+
default = { country_id: Country.default.id }
|
140
|
+
@order.build_bill_address(default) unless @order.bill_address
|
141
|
+
@order.build_ship_address(default) if @order.checkout_steps.include?('delivery') && !@order.ship_address
|
142
|
+
end
|
146
143
|
|
147
|
-
|
148
|
-
|
149
|
-
end
|
144
|
+
def before_delivery
|
145
|
+
return if params[:order].present?
|
150
146
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
@differentiator = Spree::Stock::Differentiator.new(@order, packages)
|
155
|
-
@differentiator.missing.each do |variant, quantity|
|
156
|
-
@order.contents.remove(variant, quantity)
|
157
|
-
end
|
158
|
-
end
|
147
|
+
packages = @order.shipments.map(&:to_package)
|
148
|
+
@differentiator = Spree::Stock::Differentiator.new(@order, packages)
|
149
|
+
end
|
159
150
|
|
160
|
-
|
161
|
-
|
151
|
+
def before_payment
|
152
|
+
if @order.checkout_steps.include? "delivery"
|
153
|
+
packages = @order.shipments.map(&:to_package)
|
154
|
+
@differentiator = Spree::Stock::Differentiator.new(@order, packages)
|
155
|
+
@differentiator.missing.each do |variant, quantity|
|
156
|
+
@order.contents.remove(variant, quantity)
|
162
157
|
end
|
163
158
|
end
|
164
159
|
|
165
|
-
|
166
|
-
|
167
|
-
@order.errors.add(:base, exception.message)
|
168
|
-
render :edit
|
160
|
+
if try_spree_current_user && try_spree_current_user.respond_to?(:payment_sources)
|
161
|
+
@payment_sources = try_spree_current_user.payment_sources
|
169
162
|
end
|
163
|
+
end
|
170
164
|
|
171
|
-
|
172
|
-
|
173
|
-
|
165
|
+
def rescue_from_spree_gateway_error(exception)
|
166
|
+
flash.now[:error] = Spree.t(:spree_gateway_error_flash_for_checkout)
|
167
|
+
@order.errors.add(:base, exception.message)
|
168
|
+
render :edit
|
169
|
+
end
|
170
|
+
|
171
|
+
def check_authorization
|
172
|
+
authorize!(:edit, current_order, cookies.signed[:guest_token])
|
173
|
+
end
|
174
174
|
end
|
175
175
|
end
|