valken-shipping 2.1.0 → 2.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7149c7876c47dd7fd68ee128eb7f413d94ee777701a28a2c9e91359d1da6695
|
4
|
+
data.tar.gz: a7758713ae839296e086eed9aa57cf5532f00dabfe446b20d0e5f817b1fb3e12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a84318084bb273cb89745cff6b41cbcea9987fde4efce13a4b4f6c7357520335c701143aca2fd650b1de8a45be9033d34ab603749a4850d50413336267d5c61
|
7
|
+
data.tar.gz: 861c462c265b64a73481507abcf63694d0adb60e280459a3741521885b588206f60d84327006180c8a92a428827bf061d67223579e9fd2150e56c13fba3d63da
|
@@ -12,36 +12,5 @@ module Workarea
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
# if configuration ON, show the free shipping
|
16
|
-
# Need to add the free shipping upfront to all options so that we can use that to get discounts
|
17
|
-
# if the dicount is not available we are removing the free shipping option
|
18
|
-
def available
|
19
|
-
@available ||=
|
20
|
-
begin
|
21
|
-
all_options
|
22
|
-
all_options.unshift(get_free_shipping)
|
23
|
-
free_discount = price_adjustments["Valken Economy"]
|
24
|
-
if (free_discount.present? && free_discount.any?) || Workarea.config.show_free_shipping
|
25
|
-
all_options.first.price_adjustments = free_discount
|
26
|
-
else
|
27
|
-
all_options.shift()
|
28
|
-
end
|
29
|
-
all_options.each do |option|
|
30
|
-
option.price_adjustments = price_adjustments[option.name] || []
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_free_shipping
|
36
|
-
ShippingOption.new(
|
37
|
-
carrier: "Free Shipping",
|
38
|
-
name: "Valken Economy",
|
39
|
-
sub_name: "5 - 9 Business Days",
|
40
|
-
service_code: "Free",
|
41
|
-
price: Money.new(0.0, "USD"),
|
42
|
-
tax_code: "TAX01"
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
15
|
end
|
47
16
|
end
|
@@ -52,6 +52,7 @@ module Workarea
|
|
52
52
|
|
53
53
|
if Workarea.config.gateways.ups_carrier.class != ActiveShipping::Workarea
|
54
54
|
carrier_data.push(get_ltl_shipping)
|
55
|
+
carrier_data.push(get_free_shipping) if is_free_ship
|
55
56
|
else
|
56
57
|
return []
|
57
58
|
end
|
@@ -285,6 +286,27 @@ module Workarea
|
|
285
286
|
Workarea.config.special_region.include?(@shipping.address.region)
|
286
287
|
end
|
287
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
|
+
|
288
310
|
def product_details
|
289
311
|
# product_attributes = @order.items.map(&:product_attributes)
|
290
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
|
|