spree_api 3.7.3 → 3.7.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree_api might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89321cbba6d2a536bc10bdc0f5ec6606c298d0a0dc416732bba649804d2c0b60
|
4
|
+
data.tar.gz: cec9aa0ad43caf9a351be34395130cb53c7d288c9895efef698d24018a5af91c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c7bd0a834493213eda8232b1420ec076020b511d65ccdcfc0306d11d34b343fd55adff1b842a823644f5806ee7e141f5fb0dadad8430bb63407c6c72753153
|
7
|
+
data.tar.gz: 4ea46ad49d205de2473192924bcc64d0c439d1e2c103ec36e37abc378a33a1a3aa554b484d01138a2ad926815976c0909e93c56cc199facb9be7e0b2dc0bd103
|
@@ -90,20 +90,16 @@ module Spree
|
|
90
90
|
def remove_coupon_code
|
91
91
|
spree_authorize! :update, spree_current_order, order_token
|
92
92
|
|
93
|
-
|
94
|
-
params[:coupon_code]
|
95
|
-
else
|
96
|
-
spree_current_order.promotions.coupons.first&.code
|
97
|
-
end
|
93
|
+
coupon_codes = select_coupon_codes
|
98
94
|
|
99
|
-
return render_error_payload(Spree.t('v2.cart.no_coupon_code', scope: 'api')) if
|
95
|
+
return render_error_payload(Spree.t('v2.cart.no_coupon_code', scope: 'api')) if coupon_codes.empty?
|
100
96
|
|
101
|
-
|
97
|
+
result_errors = coupon_codes.count > 1 ? select_errors(coupon_codes) : select_error(coupon_codes)
|
102
98
|
|
103
|
-
if
|
99
|
+
if result_errors.blank?
|
104
100
|
render_serialized_payload { serialized_current_order }
|
105
101
|
else
|
106
|
-
render_error_payload(
|
102
|
+
render_error_payload(result_errors)
|
107
103
|
end
|
108
104
|
end
|
109
105
|
|
@@ -167,6 +163,28 @@ module Spree
|
|
167
163
|
params: { currency: spree_current_order.currency }
|
168
164
|
).serializable_hash
|
169
165
|
end
|
166
|
+
|
167
|
+
def select_coupon_codes
|
168
|
+
params[:coupon_code].present? ? [params[:coupon_code]] : check_coupon_codes
|
169
|
+
end
|
170
|
+
|
171
|
+
def check_coupon_codes
|
172
|
+
spree_current_order.promotions.coupons.map(&:code)
|
173
|
+
end
|
174
|
+
|
175
|
+
def select_error(coupon_codes)
|
176
|
+
result = coupon_handler.new(spree_current_order).remove(coupon_codes.first)
|
177
|
+
result.error
|
178
|
+
end
|
179
|
+
|
180
|
+
def select_errors(coupon_codes)
|
181
|
+
results = []
|
182
|
+
coupon_codes.each do |coupon_code|
|
183
|
+
results << coupon_handler.new(spree_current_order).remove(coupon_code)
|
184
|
+
end
|
185
|
+
|
186
|
+
results.select(&:error)
|
187
|
+
end
|
170
188
|
end
|
171
189
|
end
|
172
190
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.7.
|
33
|
+
version: 3.7.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.7.
|
40
|
+
version: 3.7.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rabl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|