spree_core 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +1 -0
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/order.rb +2 -2
- data/app/models/spree/order/checkout.rb +267 -267
- data/config/locales/en.yml +1 -0
- data/db/default/spree/countries.rb +1 -1
- data/db/default/spree/zones.rb +4 -9
- data/lib/spree/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf4b040c67cbc697e8ff23b19862515ad3ec40e5
|
4
|
+
data.tar.gz: 4338ea645e72ff94a0a52ffa3531319f4e64824c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68a89ef41087957b53b64bb1519040c52b9de295f6f4a0cee305f9e236bb2ecfdf474eb8f466eb0b6c80f525ebb76913db76bdddba44022e2d8732d48ba18a4
|
7
|
+
data.tar.gz: f223ee12cd500420b4c590d66918da99d69c0f1c46eaac008d18fa5164889aa2eeea266ff15867873291c6c54a78377ae1ad5befcaf321c2e2625e66089dcf44
|
@@ -92,6 +92,7 @@ module Spree
|
|
92
92
|
def define_image_method(style)
|
93
93
|
self.class.send :define_method, "#{style}_image" do |product, *options|
|
94
94
|
options = options.first || {}
|
95
|
+
options[:alt] ||= product.name
|
95
96
|
if product.images.empty?
|
96
97
|
if !product.is_a?(Spree::Variant) && !product.variant_images.empty?
|
97
98
|
create_product_image_tag(product.variant_images.first, product, options, style)
|
data/app/models/spree/address.rb
CHANGED
@@ -135,7 +135,7 @@ module Spree
|
|
135
135
|
return if !TwitterCldr::Shared::PostalCodes.territories.include?(country.iso.downcase.to_sym)
|
136
136
|
|
137
137
|
postal_code = TwitterCldr::Shared::PostalCodes.for_territory(country.iso)
|
138
|
-
errors.add(:zipcode, :invalid) if !postal_code.valid?(zipcode.to_s)
|
138
|
+
errors.add(:zipcode, :invalid) if !postal_code.valid?(zipcode.to_s.strip)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
data/app/models/spree/order.rb
CHANGED
@@ -446,7 +446,7 @@ module Spree
|
|
446
446
|
end
|
447
447
|
|
448
448
|
def create_proposed_shipments
|
449
|
-
|
449
|
+
all_adjustments.shipping.delete_all
|
450
450
|
shipments.destroy_all
|
451
451
|
self.shipments = Spree::Stock::Coordinator.new(self).shipments
|
452
452
|
end
|
@@ -595,7 +595,7 @@ module Spree
|
|
595
595
|
if shipments.empty? || shipments.any? { |shipment| shipment.shipping_rates.blank? }
|
596
596
|
# After this point, order redirects back to 'address' state and asks user to pick a proper address
|
597
597
|
# Therefore, shipments are not necessary at this point.
|
598
|
-
shipments.
|
598
|
+
shipments.destroy_all
|
599
599
|
errors.add(:base, Spree.t(:items_cannot_be_shipped)) and return false
|
600
600
|
end
|
601
601
|
end
|
@@ -1,338 +1,338 @@
|
|
1
1
|
module Spree
|
2
2
|
class Order < Spree::Base
|
3
3
|
module Checkout
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
def self.included(klass)
|
5
|
+
klass.class_eval do
|
6
|
+
class_attribute :next_event_transitions
|
7
|
+
class_attribute :previous_states
|
8
|
+
class_attribute :checkout_flow
|
9
|
+
class_attribute :checkout_steps
|
10
|
+
class_attribute :removed_transitions
|
11
|
+
|
12
|
+
self.checkout_steps ||= {}
|
13
|
+
self.next_event_transitions ||= []
|
14
|
+
self.previous_states ||= [:cart]
|
15
|
+
self.removed_transitions ||= []
|
16
|
+
|
17
|
+
def self.checkout_flow(&block)
|
18
|
+
if block_given?
|
19
|
+
@checkout_flow = block
|
20
|
+
define_state_machine!
|
21
|
+
else
|
22
|
+
@checkout_flow
|
23
|
+
end
|
24
24
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.define_state_machine!
|
28
|
-
self.checkout_steps = {}
|
29
|
-
self.next_event_transitions = []
|
30
|
-
self.previous_states = [:cart]
|
31
|
-
self.removed_transitions = []
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
26
|
+
def self.define_state_machine!
|
27
|
+
self.checkout_steps = {}
|
28
|
+
self.next_event_transitions = []
|
29
|
+
self.previous_states = [:cart]
|
30
|
+
self.removed_transitions = []
|
31
|
+
|
32
|
+
# Build the checkout flow using the checkout_flow defined either
|
33
|
+
# within the Order class, or a decorator for that class.
|
34
|
+
#
|
35
|
+
# This method may be called multiple times depending on if the
|
36
|
+
# checkout_flow is re-defined in a decorator or not.
|
37
|
+
instance_eval(&checkout_flow)
|
38
|
+
|
39
|
+
klass = self
|
40
|
+
|
41
|
+
# To avoid a ton of warnings when the state machine is re-defined
|
42
|
+
StateMachines::Machine.ignore_method_conflicts = true
|
43
|
+
# To avoid multiple occurrences of the same transition being defined
|
44
|
+
# On first definition, state_machines will not be defined
|
45
|
+
state_machines.clear if respond_to?(:state_machines)
|
46
|
+
state_machine :state, initial: :cart, use_transactions: false, action: :save_state do
|
47
|
+
klass.next_event_transitions.each { |t| transition(t.merge(on: :next)) }
|
48
|
+
|
49
|
+
# Persist the state on the order
|
50
|
+
after_transition do |order, transition|
|
51
|
+
order.state = order.state
|
52
|
+
order.state_changes.create(
|
53
|
+
previous_state: transition.from,
|
54
|
+
next_state: transition.to,
|
55
|
+
name: 'order',
|
56
|
+
user_id: order.user_id
|
57
|
+
)
|
58
|
+
order.save
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
event :cancel do
|
62
|
+
transition to: :canceled, if: :allow_cancel?
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
event :return do
|
66
|
+
transition to: :returned,
|
67
|
+
from: [:complete, :awaiting_return, :canceled],
|
68
|
+
if: :all_inventory_units_returned?
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
event :resume do
|
72
|
+
transition to: :resumed, from: :canceled, if: :canceled?
|
73
|
+
end
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
event :authorize_return do
|
76
|
+
transition to: :awaiting_return
|
77
|
+
end
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
if states[:payment]
|
80
|
+
before_transition to: :complete do |order|
|
81
|
+
if order.payment_required? && order.payments.valid.empty?
|
82
|
+
order.errors.add(:base, Spree.t(:no_payment_found))
|
83
|
+
false
|
84
|
+
elsif order.payment_required?
|
85
|
+
order.process_payments!
|
86
|
+
end
|
87
87
|
end
|
88
|
+
after_transition to: :complete, do: :persist_user_credit_card
|
89
|
+
before_transition to: :payment, do: :set_shipments_cost
|
90
|
+
before_transition to: :payment, do: :create_tax_charge!
|
91
|
+
before_transition to: :payment, do: :assign_default_credit_card
|
88
92
|
end
|
89
|
-
after_transition to: :complete, do: :persist_user_credit_card
|
90
|
-
before_transition to: :payment, do: :set_shipments_cost
|
91
|
-
before_transition to: :payment, do: :create_tax_charge!
|
92
|
-
before_transition to: :payment, do: :assign_default_credit_card
|
93
|
-
end
|
94
93
|
|
95
|
-
|
94
|
+
before_transition from: :cart, do: :ensure_line_items_present
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
if states[:address]
|
97
|
+
before_transition from: :address, do: :create_tax_charge!
|
98
|
+
before_transition to: :address, do: :assign_default_addresses!
|
99
|
+
before_transition from: :address, do: :persist_user_address!
|
100
|
+
end
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
if states[:delivery]
|
103
|
+
before_transition to: :delivery, do: :create_proposed_shipments
|
104
|
+
before_transition to: :delivery, do: :ensure_available_shipping_rates
|
105
|
+
before_transition to: :delivery, do: :set_shipments_cost
|
106
|
+
before_transition from: :delivery, do: :apply_free_shipping_promotions
|
107
|
+
end
|
109
108
|
|
110
|
-
|
111
|
-
|
109
|
+
before_transition to: :resumed, do: :ensure_line_item_variants_are_not_deleted
|
110
|
+
before_transition to: :resumed, do: :ensure_line_items_are_in_stock
|
112
111
|
|
113
|
-
|
114
|
-
|
112
|
+
before_transition to: :complete, do: :ensure_line_item_variants_are_not_deleted
|
113
|
+
before_transition to: :complete, do: :ensure_line_items_are_in_stock
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
after_transition to: :complete, do: :finalize!
|
116
|
+
after_transition to: :resumed, do: :after_resume
|
117
|
+
after_transition to: :canceled, do: :after_cancel
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
after_transition from: any - :cart, to: any - [:confirm, :complete] do |order|
|
120
|
+
order.update_totals
|
121
|
+
order.persist_totals
|
122
|
+
end
|
123
123
|
end
|
124
|
-
end
|
125
|
-
|
126
|
-
alias_method :save_state, :save
|
127
|
-
end
|
128
124
|
|
129
|
-
|
130
|
-
self.checkout_steps[name] = options
|
131
|
-
previous_states.each do |state|
|
132
|
-
add_transition({ from: state, to: name }.merge(options))
|
125
|
+
alias_method :save_state, :save
|
133
126
|
end
|
134
|
-
if options[:if]
|
135
|
-
previous_states << name
|
136
|
-
else
|
137
|
-
self.previous_states = [name]
|
138
|
-
end
|
139
|
-
end
|
140
127
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
cloned_steps = self.checkout_steps.clone
|
147
|
-
cloned_removed_transitions = self.removed_transitions.clone
|
148
|
-
checkout_flow do
|
149
|
-
cloned_steps.each_pair do |key, value|
|
150
|
-
go_to_state(name, options) if key == before
|
151
|
-
go_to_state(key, value)
|
152
|
-
go_to_state(name, options) if key == after
|
128
|
+
def self.go_to_state(name, options = {})
|
129
|
+
self.checkout_steps[name] = options
|
130
|
+
previous_states.each do |state|
|
131
|
+
add_transition({ from: state, to: name }.merge(options))
|
153
132
|
end
|
154
|
-
|
155
|
-
|
133
|
+
if options[:if]
|
134
|
+
previous_states << name
|
135
|
+
else
|
136
|
+
self.previous_states = [name]
|
156
137
|
end
|
157
138
|
end
|
158
|
-
end
|
159
139
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
140
|
+
def self.insert_checkout_step(name, options = {})
|
141
|
+
before = options.delete(:before)
|
142
|
+
after = options.delete(:after) unless before
|
143
|
+
after = self.checkout_steps.keys.last unless before || after
|
144
|
+
|
145
|
+
cloned_steps = self.checkout_steps.clone
|
146
|
+
cloned_removed_transitions = self.removed_transitions.clone
|
147
|
+
checkout_flow do
|
148
|
+
cloned_steps.each_pair do |key, value|
|
149
|
+
go_to_state(name, options) if key == before
|
150
|
+
go_to_state(key, value)
|
151
|
+
go_to_state(name, options) if key == after
|
152
|
+
end
|
153
|
+
cloned_removed_transitions.each do |transition|
|
154
|
+
remove_transition(transition)
|
155
|
+
end
|
166
156
|
end
|
167
|
-
|
168
|
-
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.remove_checkout_step(name)
|
160
|
+
cloned_steps = self.checkout_steps.clone
|
161
|
+
cloned_removed_transitions = self.removed_transitions.clone
|
162
|
+
checkout_flow do
|
163
|
+
cloned_steps.each_pair do |key, value|
|
164
|
+
go_to_state(key, value) unless key == name
|
165
|
+
end
|
166
|
+
cloned_removed_transitions.each do |transition|
|
167
|
+
remove_transition(transition)
|
168
|
+
end
|
169
169
|
end
|
170
170
|
end
|
171
|
-
end
|
172
171
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
172
|
+
def self.remove_transition(options = {})
|
173
|
+
self.removed_transitions << options
|
174
|
+
self.next_event_transitions.delete(find_transition(options))
|
175
|
+
end
|
177
176
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
177
|
+
def self.find_transition(options = {})
|
178
|
+
return nil if options.nil? || !options.include?(:from) || !options.include?(:to)
|
179
|
+
self.next_event_transitions.detect do |transition|
|
180
|
+
transition[options[:from].to_sym] == options[:to].to_sym
|
181
|
+
end
|
182
182
|
end
|
183
|
-
end
|
184
183
|
|
185
|
-
|
186
|
-
|
187
|
-
|
184
|
+
def self.checkout_step_names
|
185
|
+
self.checkout_steps.keys
|
186
|
+
end
|
188
187
|
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
def self.add_transition(options)
|
189
|
+
self.next_event_transitions << { options.delete(:from) => options.delete(:to) }.merge(options)
|
190
|
+
end
|
192
191
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
192
|
+
def checkout_steps
|
193
|
+
steps = (self.class.checkout_steps.each_with_object([]) do |(step, options), checkout_steps|
|
194
|
+
next if options.include?(:if) && !options[:if].call(self)
|
195
|
+
checkout_steps << step
|
196
|
+
end).map(&:to_s)
|
197
|
+
# Ensure there is always a complete step
|
198
|
+
steps << "complete" unless steps.include?("complete")
|
199
|
+
steps
|
200
|
+
end
|
202
201
|
|
203
|
-
|
204
|
-
|
205
|
-
|
202
|
+
def has_checkout_step?(step)
|
203
|
+
step.present? && self.checkout_steps.include?(step)
|
204
|
+
end
|
206
205
|
|
207
|
-
|
208
|
-
|
209
|
-
|
206
|
+
def passed_checkout_step?(step)
|
207
|
+
has_checkout_step?(step) && checkout_step_index(step) < checkout_step_index(state)
|
208
|
+
end
|
210
209
|
|
211
|
-
|
212
|
-
|
213
|
-
|
210
|
+
def checkout_step_index(step)
|
211
|
+
self.checkout_steps.index(step).to_i
|
212
|
+
end
|
214
213
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
214
|
+
def can_go_to_state?(state)
|
215
|
+
return false unless has_checkout_step?(self.state) && has_checkout_step?(state)
|
216
|
+
checkout_step_index(state) > checkout_step_index(self.state)
|
217
|
+
end
|
219
218
|
|
220
|
-
|
219
|
+
define_callbacks :updating_from_params, terminator: ->(_target, result) { result == false }
|
221
220
|
|
222
|
-
|
221
|
+
set_callback :updating_from_params, :before, :update_params_payment_source
|
223
222
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
223
|
+
def update_from_params(params, permitted_params, request_env = {})
|
224
|
+
success = false
|
225
|
+
@updating_params = params
|
226
|
+
run_callbacks :updating_from_params do
|
227
|
+
# Set existing card after setting permitted parameters because
|
228
|
+
# rails would slice parameters containg ruby objects, apparently
|
229
|
+
existing_card_id = @updating_params[:order] ? @updating_params[:order].delete(:existing_card) : nil
|
231
230
|
|
232
|
-
|
231
|
+
attributes = @updating_params[:order] ? @updating_params[:order].permit(permitted_params).delete_if { |_k, v| v.nil? } : {}
|
233
232
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
233
|
+
if existing_card_id.present?
|
234
|
+
credit_card = CreditCard.find existing_card_id
|
235
|
+
if credit_card.user_id != user_id || credit_card.user_id.blank?
|
236
|
+
raise Core::GatewayError.new Spree.t(:invalid_credit_card)
|
237
|
+
end
|
239
238
|
|
240
|
-
|
239
|
+
credit_card.verification_value = params[:cvc_confirm] if params[:cvc_confirm].present?
|
241
240
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
241
|
+
attributes[:payments_attributes].first[:source] = credit_card
|
242
|
+
attributes[:payments_attributes].first[:payment_method_id] = credit_card.payment_method_id
|
243
|
+
attributes[:payments_attributes].first.delete :source_attributes
|
244
|
+
end
|
245
|
+
|
246
|
+
if attributes[:payments_attributes]
|
247
|
+
attributes[:payments_attributes].first[:request_env] = request_env
|
248
|
+
end
|
246
249
|
|
247
|
-
|
248
|
-
|
250
|
+
success = update_attributes(attributes)
|
251
|
+
set_shipments_cost if shipments.any?
|
249
252
|
end
|
250
253
|
|
251
|
-
|
252
|
-
|
254
|
+
@updating_params = nil
|
255
|
+
success
|
253
256
|
end
|
254
257
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
+
def assign_default_addresses!
|
259
|
+
if user
|
260
|
+
clone_billing
|
261
|
+
# Skip setting ship address if order doesn't have a delivery checkout step
|
262
|
+
# to avoid triggering validations on shipping address
|
263
|
+
clone_shipping if checkout_steps.include?("delivery")
|
264
|
+
end
|
265
|
+
end
|
258
266
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
# to avoid triggering validations on shipping address
|
264
|
-
clone_shipping if checkout_steps.include?("delivery")
|
267
|
+
def clone_billing
|
268
|
+
if !bill_address_id && user.bill_address.try(:valid?)
|
269
|
+
self.bill_address = user.bill_address.try(:clone)
|
270
|
+
end
|
265
271
|
end
|
266
|
-
end
|
267
272
|
|
268
|
-
|
269
|
-
|
270
|
-
|
273
|
+
def clone_shipping
|
274
|
+
if !ship_address_id && user.ship_address.try(:valid?)
|
275
|
+
self.ship_address = user.ship_address.try(:clone)
|
276
|
+
end
|
271
277
|
end
|
272
|
-
end
|
273
278
|
|
274
|
-
|
275
|
-
|
276
|
-
|
279
|
+
def persist_user_address!
|
280
|
+
if !temporary_address && user && user.respond_to?(:persist_order_address) && bill_address_id
|
281
|
+
user.persist_order_address(self)
|
282
|
+
end
|
277
283
|
end
|
278
|
-
end
|
279
284
|
|
280
|
-
|
281
|
-
|
282
|
-
|
285
|
+
def persist_user_credit_card
|
286
|
+
if !temporary_credit_card && user_id && valid_credit_cards.present?
|
287
|
+
default_cc = valid_credit_cards.first
|
288
|
+
default_cc.user_id = user_id
|
289
|
+
default_cc.default = true
|
290
|
+
default_cc.save
|
291
|
+
end
|
283
292
|
end
|
284
|
-
end
|
285
293
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
default_cc.save
|
294
|
+
def assign_default_credit_card
|
295
|
+
if payments.from_credit_card.count == 0 && user_has_valid_default_card? && payment_required?
|
296
|
+
cc = user.default_credit_card
|
297
|
+
payments.create!(payment_method_id: cc.payment_method_id, source: cc, amount: total)
|
298
|
+
end
|
292
299
|
end
|
293
|
-
end
|
294
300
|
|
295
|
-
|
296
|
-
|
297
|
-
cc = user.default_credit_card
|
298
|
-
payments.create!(payment_method_id: cc.payment_method_id, source: cc, amount: total)
|
301
|
+
def user_has_valid_default_card?
|
302
|
+
user && user.default_credit_card.try(:valid?)
|
299
303
|
end
|
300
|
-
end
|
301
304
|
|
302
|
-
|
303
|
-
user && user.default_credit_card.try(:valid?)
|
304
|
-
end
|
305
|
+
private
|
305
306
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
@updating_params[:order][:payments_attributes].first[:source_attributes] = source_params
|
307
|
+
# For payment step, filter order parameters to produce the expected nested
|
308
|
+
# attributes for a single payment and its source, discarding attributes
|
309
|
+
# for payment methods other than the one selected
|
310
|
+
#
|
311
|
+
# In case a existing credit card is provided it needs to build the payment
|
312
|
+
# attributes from scratch so we can set the amount. example payload:
|
313
|
+
#
|
314
|
+
# {
|
315
|
+
# "order": {
|
316
|
+
# "existing_card": "2"
|
317
|
+
# }
|
318
|
+
# }
|
319
|
+
#
|
320
|
+
def update_params_payment_source
|
321
|
+
if @updating_params[:payment_source].present?
|
322
|
+
source_params = @updating_params.
|
323
|
+
delete(:payment_source)[@updating_params[:order][:payments_attributes].
|
324
|
+
first[:payment_method_id].to_s]
|
325
|
+
|
326
|
+
if source_params
|
327
|
+
@updating_params[:order][:payments_attributes].first[:source_attributes] = source_params
|
328
|
+
end
|
329
329
|
end
|
330
|
-
end
|
331
330
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
331
|
+
if @updating_params[:order] && (@updating_params[:order][:payments_attributes] ||
|
332
|
+
@updating_params[:order][:existing_card])
|
333
|
+
@updating_params[:order][:payments_attributes] ||= [{}]
|
334
|
+
@updating_params[:order][:payments_attributes].first[:amount] = total
|
335
|
+
end
|
336
336
|
end
|
337
337
|
end
|
338
338
|
end
|
data/config/locales/en.yml
CHANGED
data/db/default/spree/zones.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
eu_vat = Spree::Zone.create!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.")
|
2
2
|
north_america = Spree::Zone.create!(name: "North America", description: "USA + Canada")
|
3
|
-
|
4
|
-
["Poland", "Finland", "Portugal", "Romania", "Germany", "France",
|
5
|
-
"Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain",
|
6
|
-
"Italy", "Belgium", "Sweden", "Latvia", "Bulgaria", "United Kingdom",
|
7
|
-
"Lithuania", "Cyprus", "Luxembourg", "Malta", "Denmark", "Netherlands",
|
8
|
-
"Estonia"].
|
3
|
+
%w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE).
|
9
4
|
each do |name|
|
10
|
-
eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(
|
5
|
+
eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(iso: name))
|
11
6
|
end
|
12
7
|
|
13
|
-
|
14
|
-
north_america.zone_members.create!(zoneable: Spree::Country.find_by!(
|
8
|
+
%w(US CA).each do |name|
|
9
|
+
north_america.zone_members.create!(zoneable: Spree::Country.find_by!(iso: name))
|
15
10
|
end
|
16
11
|
|
17
12
|
|
data/lib/spree/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|