valken-shipping 2.0.7 → 2.1.2

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: bdf90fc1027419e570161039b4015727c9c98e2f48cb25c2dc386eaf97adfe08
4
- data.tar.gz: 12b3131e650b4fd8ff8378c634d7a016490db586cece0559cdce26158b329d7b
3
+ metadata.gz: cacab064e89193c71c7ffa74746561806dd1c9deddf236d5265afe0ff6ffbf9a
4
+ data.tar.gz: 7f37d5f91091725b12bde5c42e2911153b8e567b3ac22a7cace9dcdfb1b9e30f
5
5
  SHA512:
6
- metadata.gz: 59bdeb5734e355f53fa91aac81c6b6ae747dd30c6c3772e6e59e6f0134e26d46c78897c11d849d829db41e8d1a39948d7d724d26d42d8f7dd104f51c1f33152a
7
- data.tar.gz: 84e5b3769cb38a9b4f750443d081b419459667aa65bd0a9b5292210b194d2e05aebe1031c0c7c036555c03eb8d4db5292c70ddb69900d9d5b4ff9105ad985f86
6
+ metadata.gz: 4016bbca645c3bcfbb45972f2e4658fb7bef550bc89ce877984992b64fa648800a10f5aff957358b857b36cd2c67ba976b1ed611fc18fe8a26e564c1bb3a7551
7
+ data.tar.gz: 5e24b58edbc20c129f7fb65cf06fe00add86a8bcecd8f9b0147856abc9041d6b1974f783f634982ac8f938eac5e66dbb70f72c3a91a1bd47e4aa9ec6f5bd84f4
@@ -41,6 +41,10 @@ module Workarea
41
41
 
42
42
  return default_options(packaging.packages) if Workarea.config.gateways.ups_carrier.class == ActiveShipping::Workarea
43
43
 
44
+ if is_special_region?
45
+ return [get_shipping_for_special_region]
46
+ end
47
+
44
48
  shipping_options_api = get_final_shipping_options(collect_carrier_data)
45
49
  return [] if @error.present?
46
50
 
@@ -48,7 +52,7 @@ module Workarea
48
52
 
49
53
  if Workarea.config.gateways.ups_carrier.class != ActiveShipping::Workarea
50
54
  carrier_data.push(get_ltl_shipping)
51
- carrier_data.push(get_free_shipping) if Workarea.config.show_free_shipping
55
+ carrier_data.push(get_free_shipping) if is_free_ship
52
56
  else
53
57
  return []
54
58
  end
@@ -81,9 +85,10 @@ module Workarea
81
85
  # If the carrier is ups then it will print ups data...or if carrier is fedex then prinnt fedex data...
82
86
  # else if it is not both then choose cheapest price.
83
87
  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
88
+ return get_ups_data
89
+ # Temporarily disabling fedex and cheaper
90
+ # return get_fedex_data if is_fedex
91
+ # return get_none_data unless is_ups && is_fedex
87
92
  end
88
93
 
89
94
  # UPS data.
@@ -150,6 +155,30 @@ module Workarea
150
155
  )
151
156
  end
152
157
 
158
+ def get_shipping_for_special_region
159
+ puts "weight_convertion",weight_convertion
160
+ weight_price = 0
161
+ case weight_convertion
162
+ when 0..50
163
+ weight_price = 50
164
+ when 50..200
165
+ weight_price = (1 * weight_convertion)
166
+ when 200..2500
167
+ weight_price = 200
168
+ else
169
+ weight_price = ((weight_convertion / 2500).ceil()) * 200
170
+ end
171
+
172
+ ShippingOption.new(
173
+ carrier: "LTL Shipping",
174
+ name: "Valken Standard",
175
+ sub_name: "3 - 5 Business Days",
176
+ service_code: "LTL01",
177
+ price: Money.new(weight_price * 100, "USD"),
178
+ tax_code: "TAX01"
179
+ )
180
+ end
181
+
153
182
  # Returns the total weight.
154
183
  def weight_convertion
155
184
  packaging = Packaging.new(order, shipping)
@@ -252,7 +281,32 @@ module Workarea
252
281
  product_carrier_type = product_details.map{ |item| item[:en][ground_ship_attribute] }.flatten
253
282
  product_carrier_type.include?("true")
254
283
  end
255
-
284
+
285
+ def is_special_region?
286
+ Workarea.config.special_region.include?(@shipping.address.region)
287
+ end
288
+
289
+ # if any of the product is NO FREE SHIPPING = TRUE then return false
290
+ # if free shipping config is then return true
291
+ # if user applies free shipping promo code then return true
292
+ def is_free_ship
293
+ free_ship_attribute = Workarea.config.shipping_attributes[:no_free_shipping]
294
+ product_carrier_type = product_details.map{ |item| item[:en][free_ship_attribute] }.flatten
295
+ return false if product_carrier_type.include?("true")
296
+
297
+ return true if Workarea.config.show_free_shipping
298
+
299
+ test_order = order.clone
300
+ test_shipping = shipping.clone
301
+ test_shipping.apply_shipping_service(get_free_shipping.to_h)
302
+
303
+ price_adjustments = Pricing.find_shipping_discounts(
304
+ test_order,
305
+ test_shipping
306
+ )
307
+ return price_adjustments.present? && price_adjustments.any?
308
+ end
309
+
256
310
  def product_details
257
311
  # product_attributes = @order.items.map(&:product_attributes)
258
312
 
@@ -5,7 +5,8 @@ Workarea::Configuration.define_fields do
5
5
  default: {
6
6
  'usa_only' => 'usa only',
7
7
  'carrier_type' => 'Type',
8
- 'ground_shipping_only' => 'ground shipping only'
8
+ 'ground_shipping_only' => 'ground shipping only',
9
+ 'no_free_shipping' => 'no free shipping'
9
10
  },
10
11
  description: 'Mapping of product details keys with shipping logic. Note: This maps only the keys not the values.'
11
12
 
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '2.0.7'
3
+ VERSION = '2.1.2'
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.7
4
+ version: 2.1.2
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-18 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails