valken-shipping 2.0.1 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdf90fc1027419e570161039b4015727c9c98e2f48cb25c2dc386eaf97adfe08
|
4
|
+
data.tar.gz: 12b3131e650b4fd8ff8378c634d7a016490db586cece0559cdce26158b329d7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59bdeb5734e355f53fa91aac81c6b6ae747dd30c6c3772e6e59e6f0134e26d46c78897c11d849d829db41e8d1a39948d7d724d26d42d8f7dd104f51c1f33152a
|
7
|
+
data.tar.gz: 84e5b3769cb38a9b4f750443d081b419459667aa65bd0a9b5292210b194d2e05aebe1031c0c7c036555c03eb8d4db5292c70ddb69900d9d5b4ff9105ad985f86
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Workarea
|
2
2
|
module AddressesHelper
|
3
3
|
def country_options
|
4
|
-
return [[Country['US'].name, Country['US'].alpha2]] if is_usa_only?
|
5
4
|
Workarea.config.countries.map do |country|
|
6
5
|
[country.name, country.alpha2]
|
7
6
|
end
|
@@ -13,17 +12,29 @@ module Workarea
|
|
13
12
|
.map { |id, region| [region.translations[I18n.locale.to_s] || region.name, id] }
|
14
13
|
.sort_by { |name, id| name || id }
|
15
14
|
|
16
|
-
|
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
|
17
23
|
memo
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
27
|
def is_usa_only?
|
22
|
-
|
28
|
+
|
29
|
+
orders = current_order rescue nil
|
30
|
+
return false if orders.blank? || orders.items.blank?
|
23
31
|
|
24
32
|
usa_only_attribute = Workarea.config.shipping_attributes[:usa_only]
|
25
|
-
|
26
|
-
|
33
|
+
return product_details(orders).map{ |item| item[:en][usa_only_attribute] }.flatten.include?("true")
|
34
|
+
end
|
35
|
+
|
36
|
+
def product_details(orders)
|
37
|
+
@product_details ||= Catalog::Product.in(id: orders.items.to_a.map(&:product_id)).pluck(:details)
|
27
38
|
end
|
28
39
|
|
29
40
|
def formatted_address(address)
|
@@ -36,7 +47,6 @@ module Workarea
|
|
36
47
|
postalcode: address.postal_code,
|
37
48
|
country: address.country.alpha2
|
38
49
|
}
|
39
|
-
|
40
50
|
address_format = address.country.address_format || Country['US'].address_format
|
41
51
|
result = pieces.reduce(address_format) do |memo, (name, value)|
|
42
52
|
memo.gsub(/{{#{name}}}/, html_escape(value.to_s))
|
@@ -15,12 +15,33 @@ module Workarea
|
|
15
15
|
@shipping
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
def default_options(packages)
|
20
|
+
return [] if address.blank? || packages.blank?
|
21
|
+
shipping_option = Workarea.config.gateways.shipping
|
22
|
+
|
23
|
+
origin = ActiveShipping::Location.new(Workarea.config.shipping_origin)
|
24
|
+
response = shipping_option.find_rates(
|
25
|
+
origin,
|
26
|
+
address.to_active_shipping,
|
27
|
+
packages
|
28
|
+
)
|
29
|
+
response.rates.sort_by(&:price).map do |rate|
|
30
|
+
ShippingOption.from_rate_estimate(rate)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
18
34
|
def find_method_options(order, shipping)
|
19
35
|
@order ||= order
|
20
36
|
@shipping ||= shipping
|
21
37
|
carrier_data = []
|
22
|
-
shipping_options_api = get_final_shipping_options(collect_carrier_data)
|
23
38
|
|
39
|
+
packaging = Packaging.new(order, shipping)
|
40
|
+
return [] if packaging.packages.blank?
|
41
|
+
|
42
|
+
return default_options(packaging.packages) if Workarea.config.gateways.ups_carrier.class == ActiveShipping::Workarea
|
43
|
+
|
44
|
+
shipping_options_api = get_final_shipping_options(collect_carrier_data)
|
24
45
|
return [] if @error.present?
|
25
46
|
|
26
47
|
carrier_data.push(shipping_options_api) if shipping_options_api.present? && shipping_options_api.any?
|
@@ -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.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sushmitha02
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|