valken-shipping 2.0.3 → 2.0.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: f9818be8a62cad5c315d34ab0f92ad3329e92cc783239a7e79eb2d0a1ef57ed6
4
- data.tar.gz: b4ce33dbb4c6521fd0bba0aa7be81d14141bd44d6f9e98ab3b05580b418c8027
3
+ metadata.gz: b68ecff826d216873de1e906063c2c349d0a9d3c0e23581a90eb05831c67e5a7
4
+ data.tar.gz: 4967817ff6b397f68a9ad7237acd167d9c3ffe8e3e0434dd053864ddc5539ec5
5
5
  SHA512:
6
- metadata.gz: aefdbcffb8b51ff670231ad598a339fb4f8184f3670252d0d982136c5b13c834a913dd8db3b581b72bf89b9e393c1f77411e4e805b149042dd4ed72048453652
7
- data.tar.gz: 676daa8bcf724b0c134e66bfc95ace4fa8be4ad3745c422badfd794c8ff64bae749e48ed87664a2896a54f00f52b33f3c8fb659f6aa2e804530a198befc3689c
6
+ metadata.gz: 123282661e08331848b3442c0ae389c86efd1ae767df922c70a1b7b93b4a90bb40317948b941dc30a588838d20c60baadfd351d98ce564eec95df35f1ef88997
7
+ data.tar.gz: 6c4c59add44238adecee109dc536897fab93a1c73dfb670f313a100713f0721b19c71affd633ae853cd6d45f7a0cc95cdb285b7206e1d4310308bd4748922377
@@ -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,19 +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
- memo << [country.name, regions]
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
+
23
29
  orders = current_order rescue nil
24
30
  return false if orders.blank? || orders.items.blank?
25
31
 
26
32
  usa_only_attribute = Workarea.config.shipping_attributes[:usa_only]
27
- product_attributes = orders.items.map(&:product_attributes)
28
- return product_attributes.map{ |item| item[:details][:en][usa_only_attribute] }.flatten.include?("true")
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)
29
38
  end
30
39
 
31
40
  def formatted_address(address)
@@ -38,7 +47,6 @@ module Workarea
38
47
  postalcode: address.postal_code,
39
48
  country: address.country.alpha2
40
49
  }
41
-
42
50
  address_format = address.country.address_format || Country['US'].address_format
43
51
  result = pieces.reduce(address_format) do |memo, (name, value)|
44
52
  memo.gsub(/{{#{name}}}/, html_escape(value.to_s))
@@ -81,9 +81,10 @@ module Workarea
81
81
  # If the carrier is ups then it will print ups data...or if carrier is fedex then prinnt fedex data...
82
82
  # else if it is not both then choose cheapest price.
83
83
  def collect_carrier_data
84
- return get_ups_data if is_ups
85
- return get_fedex_data if is_fedex
86
- return get_none_data unless is_ups && is_fedex
84
+ return get_ups_data
85
+ # Temporarily disabling fedex and cheaper
86
+ # return get_fedex_data if is_fedex
87
+ # return get_none_data unless is_ups && is_fedex
87
88
  end
88
89
 
89
90
  # UPS data.
@@ -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
@@ -1,4 +1,7 @@
1
1
  Workarea.configure do |config|
2
+
3
+ config.countries = [Country['US']]
4
+
2
5
  ActiveShipping::Carriers.register :UPS, 'active_shipping/carriers/ups'
3
6
 
4
7
  config.weight_table = {"2": 5, "15": 15, "200": 1, "2500": 200}
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '2.0.3'
3
+ VERSION = '2.0.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: 2.0.3
4
+ version: 2.0.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-09-07 00:00:00.000000000 Z
11
+ date: 2020-09-22 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.8
75
+ rubygems_version: 3.0.6
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: shipping options