valken-shipping 3.0.2 → 3.0.3.pre

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: d75de69e6cf65115669bdcd1a2c662ec266b3aed8d7cc769e72e9bac336baa7e
4
- data.tar.gz: c43b08dc302d9a98931e5173ff18af67b7403cc53004fd0a6d7bea5cbb1d8d17
3
+ metadata.gz: bcfa8404b116337a84e98d859e0490b2c306ca286337be2fd64436add9ca7323
4
+ data.tar.gz: 24a83e8fa9abfd9e9c5e57e37db4beaf4f4abab4a45c1b1bbbca23b5bae56ebc
5
5
  SHA512:
6
- metadata.gz: de828f51c73f612bf7939e277e1eaa495ca86f9287ba1f17562a0b74b6d88970cb57306ccb8143fd9dc86ff27d6a21d8cfb1660281ee190f3cd3f19ba31d4fed
7
- data.tar.gz: c6edd088265f12e9dd6d599dd3c7a4350a12cff1b586c082113ac12695bfd2866e2ee1931a7ec8a3c0461c89324c01ef338d127f76e4c4120fd8e5b6aa366601
6
+ metadata.gz: 95791f77bb3756a6ab9fc00e15dc18723da1953133db0092738f55f36e630b2ccb465d38c248939775158a1e14c04dfec726d7716e82b0611cab1351041dbd0c
7
+ data.tar.gz: 1a0aa5af87a183054ec21a491e3ed03d6e69990ac62934b5f00c84aeb47b8a8984c49b7499e5639cf7efd55d4eac67e0af177cded9222a0b20b10daccb3b9782
@@ -47,16 +47,31 @@ module Workarea
47
47
  packaging.packages,
48
48
  {
49
49
  ground: is_ground,
50
- special_region: is_special_region?
50
+ special_region: is_special_region?,
51
+ free_shipping: is_free_ship
51
52
  }
52
53
  )
53
54
  shipping_options = response.rates.sort_by(&:price).map do |rate|
54
55
  ShippingOption.from_rate_estimate(rate)
55
56
  end
56
57
 
58
+ shipping_options.unshift(get_free_shipping) if is_free_ship
57
59
  shipping_options
58
60
  end
59
61
 
62
+
63
+ # Free shipping option.
64
+ def get_free_shipping
65
+ ShippingOption.new(
66
+ carrier: "Free Shipping",
67
+ name: "Valken Economy",
68
+ sub_name: "5 - 9 Business Days",
69
+ service_code: "Free",
70
+ price: Money.new(0.0, Money.default_currency.to_s),
71
+ tax_code: "TAX01"
72
+ )
73
+ end
74
+
60
75
  def is_ground
61
76
  ground_ship_attribute = Workarea.config.shipping_attributes[:ground_shipping_only]
62
77
  product_carrier_type = product_details.map{ |item| item[:en][ground_ship_attribute] }.flatten
@@ -67,6 +82,27 @@ module Workarea
67
82
  Workarea.config.special_region.include?(@shipping.address.region)
68
83
  end
69
84
 
85
+ # if any of the product is NO FREE SHIPPING = TRUE then return false
86
+ # if free shipping config is then return true
87
+ # if user applies free shipping promo code then return true
88
+ def is_free_ship
89
+ free_ship_attribute = Workarea.config.shipping_attributes[:no_free_shipping]
90
+ product_carrier_type = product_details.map{ |item| item[:en][free_ship_attribute] }.flatten
91
+ return false if product_carrier_type.include?("true")
92
+
93
+ return true if Workarea.config.show_free_shipping
94
+
95
+ test_order = order.clone
96
+ test_shipping = shipping.clone
97
+ test_shipping.apply_shipping_service(get_free_shipping.to_h)
98
+
99
+ price_adjustments = Pricing.find_shipping_discounts(
100
+ test_order,
101
+ test_shipping
102
+ )
103
+ return price_adjustments.present? && price_adjustments.any?
104
+ end
105
+
70
106
  def product_details
71
107
  # product_attributes = @order.items.map(&:product_attributes)
72
108
 
@@ -61,14 +61,13 @@
61
61
  %td= text_field_tag "rates[#{rate.id}][tier_weight_max]", rate.tier_weight_max, class: 'text-box'
62
62
  %td= text_field_tag "rates[#{rate.id}][tier_min]", rate.tier_min, class: 'text-box'
63
63
  %td= text_field_tag "rates[#{rate.id}][tier_max]", rate.tier_max, class: 'text-box'
64
- %td= check_box_tag 'rates_to_remove[]', rate.id, false, id: nil
65
-
64
+ %td= check_box_tag 'rates_to_remove[]', rate.id
66
65
  %tr{ data: { cloneable_row: '' } }
67
66
  %td= text_field_tag 'new_rates[][price]', '', placeholder: 'New Price Tier', class: 'text-box'
68
67
  %td= text_field_tag 'new_rates[][tier_weight_min]', '', placeholder: 'Min Weight Value', class: 'text-box'
69
68
  %td= text_field_tag 'new_rates[][tier_weight_max]', '', placeholder: 'Max Weight Value', class: 'text-box'
70
69
  %td= text_field_tag 'new_rates[][tier_min]', '', placeholder: 'Min Value', class: 'text-box'
71
- %td= text_field_tag 'new_rates[][tier_max]', '', placeholder: 'Min Value', class: 'text-box'
70
+ %td= text_field_tag 'new_rates[][tier_min]', '', placeholder: 'Min Value', class: 'text-box'
72
71
  %td
73
72
 
74
73
  .workflow-bar
@@ -4,9 +4,7 @@ module ActiveShipping
4
4
  class VALKEN < UPS
5
5
 
6
6
  def find_rates(origin, destination, packages, options = {})
7
- if options[:ground] || (::Workarea.config.default_shipping)
8
- return get_workarea_services(origin, destination, packages, options)
9
- end
7
+ return get_workarea_rates(origin, destination, packages, options) if options[:ground]
10
8
  super
11
9
  end
12
10
 
@@ -36,8 +34,7 @@ module ActiveShipping
36
34
  end
37
35
 
38
36
  workarea_rates = get_workarea_services(origin, destination, packages, options).rates
39
-
40
- if message.include?("Failure: Maximum number of packages exceeded")
37
+ if message == "Failure: Maximum number of packages exceeded (200)"
41
38
  RateResponse.new(true, "Only workarea shipping service", {}, rates: workarea_rates, xml: "", request: "")
42
39
  else
43
40
  RateResponse.new(success, message, Hash.from_xml(response).values.first, rates:(filtered_rates + workarea_rates).flatten, xml: response, request: last_request)
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '3.0.2'.freeze
3
+ VERSION = '3.0.3.pre'.freeze
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: 3.0.2
4
+ version: 3.0.3.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - sushmitha02
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -76,9 +76,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - ">"
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: 1.3.1
82
82
  requirements: []
83
83
  rubygems_version: 3.0.3
84
84
  signing_key: