valken-shipping 2.0.1 → 2.0.3

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: f92653930081ded5658da35cbc0c04e556b15cf001fab963f589ebaf86501a88
4
- data.tar.gz: 7996b9957c6aec16a394f4a772aa650410613c88819569536a8cf1585567c5a2
3
+ metadata.gz: f9818be8a62cad5c315d34ab0f92ad3329e92cc783239a7e79eb2d0a1ef57ed6
4
+ data.tar.gz: b4ce33dbb4c6521fd0bba0aa7be81d14141bd44d6f9e98ab3b05580b418c8027
5
5
  SHA512:
6
- metadata.gz: 24df18e3b0c8db49d6074ecb675c59aa450b62cbfd7849a3446a65e21474f817ea51b82aef96b25a857dc2cd4b9fc7934edb59d465aeef8fe87954b91e38d492
7
- data.tar.gz: 8e6b3cce596b96e97f1ade2081b0fa54ed429581806e0d45f776d1a89ced2cb8279fc685341823628d901b839c74b90a1a9879d8d565319ff7da75f0de789828
6
+ metadata.gz: aefdbcffb8b51ff670231ad598a339fb4f8184f3670252d0d982136c5b13c834a913dd8db3b581b72bf89b9e393c1f77411e4e805b149042dd4ed72048453652
7
+ data.tar.gz: 676daa8bcf724b0c134e66bfc95ace4fa8be4ad3745c422badfd794c8ff64bae749e48ed87664a2896a54f00f52b33f3c8fb659f6aa2e804530a198befc3689c
@@ -19,10 +19,12 @@ module Workarea
19
19
  end
20
20
 
21
21
  def is_usa_only?
22
- return false if current_order.blank? || current_order.items.blank?
22
+
23
+ orders = current_order rescue nil
24
+ return false if orders.blank? || orders.items.blank?
23
25
 
24
26
  usa_only_attribute = Workarea.config.shipping_attributes[:usa_only]
25
- product_attributes = current_order.items.map(&:product_attributes)
27
+ product_attributes = orders.items.map(&:product_attributes)
26
28
  return product_attributes.map{ |item| item[:details][:en][usa_only_attribute] }.flatten.include?("true")
27
29
  end
28
30
 
@@ -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?
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '2.0.1'
3
+ VERSION = '2.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valken-shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sushmitha02
@@ -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.6
75
+ rubygems_version: 3.0.8
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: shipping options