valken-shipping 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/workarea/addresses_helper.rb +8 -2
- data/app/models/workarea/checkout/shipping_options.decorator +31 -0
- data/app/models/workarea/shipping.decorator +37 -5
- data/config/initializers/shipping_configuration.rb +5 -0
- data/lib/valken/shipping/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21051b703831eeb8b7db181812b3231971498df95778ce15ba3a8ba27fde910e
|
4
|
+
data.tar.gz: 751fcb5af0f175a504a61b4b08fabd6ea1db859b3f5b23d6c914cbeb7febebf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39793ffff0a296b60c70221ed76fdb19c1d8516f853efe6e773e779622f4c09bf6badcdf84dafec9676ed2791aee8f1119bcd5b0393143b109a06722b43a0d99
|
7
|
+
data.tar.gz: aa0d815b9d042f655377f468d8679dfa5d6572fe7776a4536fd877e29a717b2aac9cb889569560c782a882955399df48dd6a3ec9e090ce2f14771bfb2842c67d
|
@@ -12,7 +12,14 @@ module Workarea
|
|
12
12
|
.map { |id, region| [region.translations[I18n.locale.to_s] || region.name, id] }
|
13
13
|
.sort_by { |name, id| name || id }
|
14
14
|
|
15
|
-
|
15
|
+
if country.name == "United States of America"
|
16
|
+
region = regions.reject do |state|
|
17
|
+
Workarea.config.shipping_state_exclude.include?(state.last)
|
18
|
+
end
|
19
|
+
memo << [country.name, region]
|
20
|
+
else
|
21
|
+
memo << [country.name, regions]
|
22
|
+
end
|
16
23
|
memo
|
17
24
|
end
|
18
25
|
end
|
@@ -40,7 +47,6 @@ module Workarea
|
|
40
47
|
postalcode: address.postal_code,
|
41
48
|
country: address.country.alpha2
|
42
49
|
}
|
43
|
-
|
44
50
|
address_format = address.country.address_format || Country['US'].address_format
|
45
51
|
result = pieces.reduce(address_format) do |memo, (name, value)|
|
46
52
|
memo.gsub(/{{#{name}}}/, html_escape(value.to_s))
|
@@ -12,5 +12,36 @@ module Workarea
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# if configuration ON, show the free shipping
|
16
|
+
# Need to add the free shipping upfront to all options so that we can use that to get discounts
|
17
|
+
# if the dicount is not available we are removing the free shipping option
|
18
|
+
def available
|
19
|
+
@available ||=
|
20
|
+
begin
|
21
|
+
all_options
|
22
|
+
all_options.unshift(get_free_shipping)
|
23
|
+
free_discount = price_adjustments["Valken Economy"]
|
24
|
+
if (free_discount.present? && free_discount.any?) || Workarea.config.show_free_shipping
|
25
|
+
all_options.first.price_adjustments = free_discount
|
26
|
+
else
|
27
|
+
all_options.shift()
|
28
|
+
end
|
29
|
+
all_options.each do |option|
|
30
|
+
option.price_adjustments = price_adjustments[option.name] || []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_free_shipping
|
36
|
+
ShippingOption.new(
|
37
|
+
carrier: "Free Shipping",
|
38
|
+
name: "Valken Economy",
|
39
|
+
sub_name: "5 - 9 Business Days",
|
40
|
+
service_code: "Free",
|
41
|
+
price: Money.new(0.0, "USD"),
|
42
|
+
tax_code: "TAX01"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
15
46
|
end
|
16
47
|
end
|
@@ -41,6 +41,10 @@ module Workarea
|
|
41
41
|
|
42
42
|
return default_options(packaging.packages) if Workarea.config.gateways.ups_carrier.class == ActiveShipping::Workarea
|
43
43
|
|
44
|
+
if is_special_region?
|
45
|
+
return [get_shipping_for_special_region]
|
46
|
+
end
|
47
|
+
|
44
48
|
shipping_options_api = get_final_shipping_options(collect_carrier_data)
|
45
49
|
return [] if @error.present?
|
46
50
|
|
@@ -48,7 +52,6 @@ module Workarea
|
|
48
52
|
|
49
53
|
if Workarea.config.gateways.ups_carrier.class != ActiveShipping::Workarea
|
50
54
|
carrier_data.push(get_ltl_shipping)
|
51
|
-
carrier_data.push(get_free_shipping) if Workarea.config.show_free_shipping
|
52
55
|
else
|
53
56
|
return []
|
54
57
|
end
|
@@ -81,9 +84,10 @@ module Workarea
|
|
81
84
|
# If the carrier is ups then it will print ups data...or if carrier is fedex then prinnt fedex data...
|
82
85
|
# else if it is not both then choose cheapest price.
|
83
86
|
def collect_carrier_data
|
84
|
-
return get_ups_data
|
85
|
-
|
86
|
-
return
|
87
|
+
return get_ups_data
|
88
|
+
# Temporarily disabling fedex and cheaper
|
89
|
+
# return get_fedex_data if is_fedex
|
90
|
+
# return get_none_data unless is_ups && is_fedex
|
87
91
|
end
|
88
92
|
|
89
93
|
# UPS data.
|
@@ -150,6 +154,30 @@ module Workarea
|
|
150
154
|
)
|
151
155
|
end
|
152
156
|
|
157
|
+
def get_shipping_for_special_region
|
158
|
+
puts "weight_convertion",weight_convertion
|
159
|
+
weight_price = 0
|
160
|
+
case weight_convertion
|
161
|
+
when 0..15
|
162
|
+
weight_price = 50
|
163
|
+
when 15..200
|
164
|
+
weight_price = (1 * weight_convertion)
|
165
|
+
when 200..2500
|
166
|
+
weight_price = 200
|
167
|
+
else
|
168
|
+
weight_price = ((weight_convertion / 2500).ceil()) * 200
|
169
|
+
end
|
170
|
+
|
171
|
+
ShippingOption.new(
|
172
|
+
carrier: "LTL Shipping",
|
173
|
+
name: "Valken Standard",
|
174
|
+
sub_name: "3 - 5 Business Days",
|
175
|
+
service_code: "LTL01",
|
176
|
+
price: Money.new(weight_price * 100, "USD"),
|
177
|
+
tax_code: "TAX01"
|
178
|
+
)
|
179
|
+
end
|
180
|
+
|
153
181
|
# Returns the total weight.
|
154
182
|
def weight_convertion
|
155
183
|
packaging = Packaging.new(order, shipping)
|
@@ -252,7 +280,11 @@ module Workarea
|
|
252
280
|
product_carrier_type = product_details.map{ |item| item[:en][ground_ship_attribute] }.flatten
|
253
281
|
product_carrier_type.include?("true")
|
254
282
|
end
|
255
|
-
|
283
|
+
|
284
|
+
def is_special_region?
|
285
|
+
Workarea.config.special_region.include?(@shipping.address.region)
|
286
|
+
end
|
287
|
+
|
256
288
|
def product_details
|
257
289
|
# product_attributes = @order.items.map(&:product_attributes)
|
258
290
|
|
@@ -8,5 +8,10 @@ Workarea::Configuration.define_fields do
|
|
8
8
|
'ground_shipping_only' => 'ground shipping only'
|
9
9
|
},
|
10
10
|
description: 'Mapping of product details keys with shipping logic. Note: This maps only the keys not the values.'
|
11
|
+
|
12
|
+
field 'Shipping State Exclude',
|
13
|
+
type: :array,
|
14
|
+
default: ["AK", "HI", "PR"],
|
15
|
+
description: 'Shipping Excluded States'
|
11
16
|
end
|
12
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valken-shipping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sushmitha02
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
rubygems_version: 3.0.
|
75
|
+
rubygems_version: 3.0.8
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: shipping options
|