valken-shipping 1.1.4 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b1ed71fdb852fdbd8b1ca1018fb950435b4860fe86fb6a06b6cff3b76da06d
|
4
|
+
data.tar.gz: 24da7f5bd45aee0254d206c949f7cac835fa74ee2e98d18135eb5cd046bc7c0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabbba71a4d896abddc6b05797d8cd8fbbaa5eb9a2fa3a2066a0e4f93b0559c5d097a99d3f3bece098b4a229adf5615acff7f5dc84a652bfe2cec62430e52515
|
7
|
+
data.tar.gz: 4173b8f446c15d72b96f4df7856739a2b1b6fdd20b647e0855de69de5906448bd00050cea9a8d9f315961d5bb042cbe71b43a25408b56ced44406350179e3af3
|
@@ -12,12 +12,13 @@ module Workarea
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def shipping_option
|
15
|
-
carrier_data =
|
15
|
+
carrier_data = []
|
16
16
|
if Workarea.config.gateways.ups_carrier.class != ActiveShipping::Workarea
|
17
|
-
carrier_data.push(get_ltl_shipping)
|
18
17
|
carrier_data.push(get_free_shipping) if Workarea.config.show_free_shipping
|
18
|
+
carrier_data.push(get_ltl_shipping)
|
19
19
|
end
|
20
|
-
carrier_data
|
20
|
+
carrier_data.push(collect_carrier_data(selected_carrier))
|
21
|
+
carrier_data.flatten
|
21
22
|
end
|
22
23
|
|
23
24
|
# Selecting the shipping carrier based on order items
|
@@ -79,7 +80,8 @@ module Workarea
|
|
79
80
|
def get_free_shipping
|
80
81
|
ShippingOption.new(
|
81
82
|
carrier: "Free Shipping",
|
82
|
-
name: "
|
83
|
+
name: "Valken Economy",
|
84
|
+
sub_name: "5 - 9 Business Days",
|
83
85
|
service_code: "Free",
|
84
86
|
price: Money.new(0.0, "USD"),
|
85
87
|
tax_code: "TAX01"
|
@@ -104,7 +106,8 @@ module Workarea
|
|
104
106
|
|
105
107
|
ShippingOption.new(
|
106
108
|
carrier: "LTL Shipping",
|
107
|
-
name: "
|
109
|
+
name: "Valken Standard",
|
110
|
+
sub_name: "3 - 5 Business Days",
|
108
111
|
service_code: "LTL01",
|
109
112
|
price: Money.new(weight_price * 100, "USD"),
|
110
113
|
tax_code: "TAX01"
|
@@ -158,24 +161,29 @@ module Workarea
|
|
158
161
|
|
159
162
|
# find and sort all delivery dates and pick 1st three
|
160
163
|
all_delivery_dates = rates.map { |rate| rate.delivery_date }
|
161
|
-
|
164
|
+
# sorting the uniq delivery dates and reversing those delivery dates.
|
165
|
+
uniq_delivery_dates = all_delivery_dates.compact.sort.uniq[0..2].reverse
|
162
166
|
|
167
|
+
# removing overnight. Assuming the 3rd option is always overnight
|
168
|
+
uniq_delivery_dates.pop if uniq_delivery_dates.length == 3
|
169
|
+
|
163
170
|
# For each delivery dates, find cheapest rates and create shipping option and push
|
164
171
|
uniq_delivery_dates.each_with_index do |date, index|
|
165
172
|
selected_rates = rates.select {|rate| rate.delivery_date.present? && rate.delivery_date == date}
|
166
173
|
cheap_rate = selected_rates.sort_by(&:price).first
|
167
|
-
description = "#{cheap_rate.delivery_date.strftime('%
|
168
|
-
shipping_option = create_shipping_options(cheap_rate, service_code[index], description)
|
174
|
+
description = "#{cheap_rate.delivery_date.strftime('%A, %B %d, %Y')}"
|
175
|
+
shipping_option = create_shipping_options(cheap_rate, service_code[index], description, Workarea.config.shipping_rates[index])
|
169
176
|
filtered_rates.push(shipping_option)
|
170
177
|
end
|
171
178
|
filtered_rates
|
172
179
|
end
|
173
180
|
|
174
181
|
# creating a ShippingOption
|
175
|
-
def create_shipping_options(rate, rate_label = nil, description = nil)
|
182
|
+
def create_shipping_options(rate, rate_label = nil, description = nil, sub_name)
|
176
183
|
ShippingOption.new(
|
177
184
|
carrier: rate.carrier,
|
178
|
-
name: rate_label || rate.service_name,
|
185
|
+
name: rate_label.keys.join || rate.service_name,
|
186
|
+
sub_name: sub_name.values.join,
|
179
187
|
service_code: rate.service_code,
|
180
188
|
description: description,
|
181
189
|
price: Money.new(rate.price, rate.currency),
|
@@ -185,7 +193,5 @@ module Workarea
|
|
185
193
|
)
|
186
194
|
)
|
187
195
|
end
|
188
|
-
|
189
|
-
|
190
196
|
end
|
191
197
|
end
|
@@ -3,13 +3,11 @@ Workarea.configure do |config|
|
|
3
3
|
|
4
4
|
config.weight_table = {"2": 5, "15": 15, "200": 1, "2500": 200}
|
5
5
|
|
6
|
-
|
7
6
|
config.shipping_rates = [
|
8
|
-
"
|
9
|
-
"2
|
10
|
-
"3 Day"
|
7
|
+
{"Valken Express 3-Day" => "3 Business Days"},
|
8
|
+
{"Valken Express 2-Day" => "2 Business Days"}
|
11
9
|
]
|
12
|
-
config.ups_options = {"12"=> "3
|
13
|
-
config.fedex_options = {"STANDARD_OVERNIGHT"=> "Overnight", "FEDEX_2_DAY"=> "2
|
10
|
+
config.ups_options = {"12"=> "Valken Express 3-Day", "01"=> "Valken Overnight", "02"=> "Valken Express 2-Day"}
|
11
|
+
config.fedex_options = {"STANDARD_OVERNIGHT"=> "Valken Overnight", "FEDEX_2_DAY"=> "Valken Express 2-Day", "GROUND_HOME_DELIVERY"=> "Valken Express 3-Day"}
|
14
12
|
end
|
15
13
|
Valken::Shipping.auto_initialize_gateway
|
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: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sushmitha02
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|