valken-shipping 1.1.3 → 1.1.8

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: 836864919e7e6f3dcb1762f14ea620afd0c56429040ad133fa7b01bf032cc6a3
4
- data.tar.gz: 1f0addf9f86025e5f59232cbce1cdefd9dd7b56709969823264c3e50578251b8
3
+ metadata.gz: 1f96335c5b53614036b3991c54ec307ace739a6991fbb3c1e4dd98a957a3afb6
4
+ data.tar.gz: 5d7a5f6347d2edcd2d46e4053e78843c47055b64d076f448da69593dc097b3df
5
5
  SHA512:
6
- metadata.gz: 465f4ab7305bc7c8efa1e8de744ff6a058f05f0afe389d91e8a0f79a126d12c9a2ba5109869fc39bdda63a4027c78742f6711c37a8e7aa57b2c283735ce4b9c6
7
- data.tar.gz: ba70cb673db53d2c44ec47ffec89785538e9fbe1e78acca8599bcecf7d0233ca1849f979c811b17348631918a953e6f6f3ab34595eb35cda55aa43506c479c37
6
+ metadata.gz: a449dc97ab566e2c2f7b30b40613b042497560ef503d7a9d4471029ead334b41001918436537942321c16f00d438502996d13fb3ac2859e0fbcab9b03807799e
7
+ data.tar.gz: db9b1c8f6766e75284cb9023e606ae034867f14fd239316c7484ea7d514d255fb132dae2d1c978613226b38d50072942446554eb3be366fa3fc97fd093b25ba6
@@ -12,12 +12,13 @@ module Workarea
12
12
  end
13
13
 
14
14
  def shipping_option
15
- carrier_data = collect_carrier_data(selected_carrier)
15
+ carrier_data = []
16
16
  if Workarea.config.gateways.ups_carrier.class != ActiveShipping::Workarea
17
+ carrier_data.push(get_free_shipping) if Workarea.config.show_free_shipping
17
18
  carrier_data.push(get_ltl_shipping)
18
- carrier_data.push(get_free_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
@@ -27,11 +28,11 @@ module Workarea
27
28
  def selected_carrier
28
29
  product_ids = order.items.to_a.map(&:product_id)
29
30
  product_details = Catalog::Product.in(id: product_ids).pluck(:details)
30
- is_hazmat = product_details.any? {|item| item["en"]["Type"] && item["en"]["Type"].first == "Hazmat"}
31
- is_gun = product_details.any? {|item| item["en"]["Type"] && item["en"]["Type"].first == "Gun"}
32
- return "UPS" if is_hazmat
33
- return "FedEx" if is_gun
34
- return "none" unless is_hazmat && is_gun
31
+ is_ups = product_details.any? {|item| item["en"]["Type"] && item["en"]["Type"].first == "UPS"}
32
+ is_fedex = product_details.any? {|item| item["en"]["Type"] && item["en"]["Type"].first == "FEDEX"}
33
+ return "UPS" if is_ups
34
+ return "FedEx" if is_fedex
35
+ return "none" unless is_ups && is_fedex
35
36
  end
36
37
 
37
38
  # If the carrier is ups then it will print ups data...or if carrier is fedex then prinnt fedex data...
@@ -79,7 +80,8 @@ module Workarea
79
80
  def get_free_shipping
80
81
  ShippingOption.new(
81
82
  carrier: "Free Shipping",
82
- name: "5 to 9 Day",
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: "3 to 5 Day",
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,26 @@ 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
- uniq_delivery_dates = all_delivery_dates.compact.sort.uniq[0..2]
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
 
163
167
  # For each delivery dates, find cheapest rates and create shipping option and push
164
168
  uniq_delivery_dates.each_with_index do |date, index|
165
169
  selected_rates = rates.select {|rate| rate.delivery_date.present? && rate.delivery_date == date}
166
170
  cheap_rate = selected_rates.sort_by(&:price).first
167
- description = "#{cheap_rate.delivery_date.strftime('%a, %d %b %Y')}"
168
- shipping_option = create_shipping_options(cheap_rate, service_code[index], description)
171
+ description = "#{cheap_rate.delivery_date.strftime('%A, %B %d, %Y')}"
172
+ shipping_option = create_shipping_options(cheap_rate, service_code[index], description, Workarea.config.shipping_rates[index])
169
173
  filtered_rates.push(shipping_option)
170
174
  end
171
175
  filtered_rates
172
176
  end
173
177
 
174
178
  # creating a ShippingOption
175
- def create_shipping_options(rate, rate_label = nil, description = nil)
179
+ def create_shipping_options(rate, rate_label = nil, description = nil, sub_name)
176
180
  ShippingOption.new(
177
181
  carrier: rate.carrier,
178
- name: rate_label || rate.service_name,
182
+ name: rate_label.keys.join || rate.service_name,
183
+ sub_name: sub_name.values.join,
179
184
  service_code: rate.service_code,
180
185
  description: description,
181
186
  price: Money.new(rate.price, rate.currency),
@@ -185,7 +190,5 @@ module Workarea
185
190
  )
186
191
  )
187
192
  end
188
-
189
-
190
193
  end
191
194
  end
@@ -1,7 +1,7 @@
1
1
  module Workarea
2
2
  decorate ShippingOption, with: :valken do
3
3
  decorated do
4
- attr_reader :description
4
+ attr_reader :description, :sub_name
5
5
  end
6
6
 
7
7
  class_methods do
@@ -3,13 +3,12 @@ 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
- "Overnight",
9
- "2 Day",
10
- "3 Day"
7
+ {"Valken Express 3-Day" => "3 Business Days"},
8
+ {"Valken Express 2-Day" => "2 Business Days"},
9
+ {"Valken Overnight" => "Overnight"}
11
10
  ]
12
- config.ups_options = {"12"=> "3 Day", "01"=> "Overnight", "02"=> "2 Day"}
13
- config.fedex_options = {"STANDARD_OVERNIGHT"=> "Overnight", "FEDEX_2_DAY"=> "2 Day", "GROUND_HOME_DELIVERY"=> "3 Day"}
11
+ config.ups_options = {"12"=> "Valken Express 3-Day", "01"=> "Valken Overnight", "02"=> "Valken Express 2-Day"}
12
+ config.fedex_options = {"STANDARD_OVERNIGHT"=> "Valken Overnight", "FEDEX_2_DAY"=> "Valken Express 2-Day", "GROUND_HOME_DELIVERY"=> "Valken Express 3-Day"}
14
13
  end
15
14
  Valken::Shipping.auto_initialize_gateway
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '1.1.3'
3
+ VERSION = '1.1.8'
4
4
  end
5
5
  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: 1.1.3
4
+ version: 1.1.8
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-03 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails