solidus_me 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/solidus_me/shipping_estimator.rb +15 -9
- data/lib/solidus_me/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7038411a1992fbe76be03e3ea54363e0a9a53bb813377951dad557aa718f3e09
|
4
|
+
data.tar.gz: 710ff6fccbe6dd9c9419fae66cd9ae77e14acb44f7a6a559f5b046d2651e670a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1d04d17d6f872b078bcd1a038bd048ad766bc8294a5ed075bf08e5f3b60af050234e15be9b92dd8b4040288591b54b04d7fd2406f0e8886f210392744f197c
|
7
|
+
data.tar.gz: bdb62ee68a0920a1cae31658760649bb4c5f6148f09afaa1a4d0920afc77323de282eea87d8ce97b2ffc387ad0cd5f09c06a1b8c65c1c51f0a0d029ef7b34142
|
@@ -32,7 +32,8 @@ module SolidusMe
|
|
32
32
|
length_cm = length(variants)
|
33
33
|
|
34
34
|
zipcode = package.order.ship_address.zipcode
|
35
|
-
services = @me_account.services.
|
35
|
+
services = @me_account.services.presence || ["SEDEX", "PAC", "Mini Envios", ".Package",
|
36
|
+
".Com"]
|
36
37
|
|
37
38
|
rates = @me_client.rates(
|
38
39
|
from: @me_account.postal_code_from,
|
@@ -41,7 +42,7 @@ module SolidusMe
|
|
41
42
|
contents_value_brl: price
|
42
43
|
)
|
43
44
|
rates.select { |rate| rate.price > 0 && services.include?(rate.service_name) }
|
44
|
-
rescue
|
45
|
+
rescue StandardError
|
45
46
|
[default_rate]
|
46
47
|
end
|
47
48
|
|
@@ -55,35 +56,40 @@ module SolidusMe
|
|
55
56
|
shipping_method.shipping_categories = Spree::ShippingCategory.all
|
56
57
|
shipping_method.available_to_users = true
|
57
58
|
end
|
59
|
+
estimate_prose = "Chegará em até #{ActionController::Base.helpers.pluralize(melhor_envio_rate.max_delivery_time,
|
60
|
+
'dia', plural: 'dias')} úteis"
|
58
61
|
|
59
62
|
Spree::ShippingRate.new(
|
60
63
|
shipment: package.shipment,
|
61
64
|
shipping_method: shipping_method,
|
62
65
|
cost: melhor_envio_rate.price,
|
63
|
-
min_delivery_time:
|
64
|
-
max_delivery_time:
|
66
|
+
min_delivery_time: melhor_envio_rate.min_delivery_time.business_days.from_now,
|
67
|
+
max_delivery_time: melhor_envio_rate.max_delivery_time.business_days.from_now,
|
68
|
+
estimate_prose: estimate_prose,
|
69
|
+
expires_in: Time.now + 2.hours
|
65
70
|
)
|
66
71
|
end
|
67
72
|
|
68
73
|
def default_rate
|
69
|
-
default_rate = Data.define(:price, :service_name, :carrier_name, :
|
74
|
+
default_rate = Data.define(:price, :service_name, :carrier_name, :min_delivery_time, :max_delivery_time)
|
70
75
|
default_rate.new(
|
71
76
|
price: 15.00,
|
72
77
|
service_name: "",
|
73
78
|
carrier_name: "Frete padrão",
|
74
|
-
|
79
|
+
min_delivery_time: 5,
|
80
|
+
max_delivery_time: 7,
|
75
81
|
)
|
76
82
|
end
|
77
83
|
|
78
|
-
def height
|
84
|
+
def height(variants)
|
79
85
|
variants.pluck(:height, :width, :depth).map(&:max).compact.max
|
80
86
|
end
|
81
87
|
|
82
|
-
def width
|
88
|
+
def width(variants)
|
83
89
|
variants.pluck(:height, :width, :depth).map { |dimensions| dimensions.sort[1] }.compact.max
|
84
90
|
end
|
85
91
|
|
86
|
-
def length
|
92
|
+
def length(variants)
|
87
93
|
variants.pluck(:height, :width, :depth).map(&:min).compact.sum
|
88
94
|
end
|
89
95
|
end
|
data/lib/solidus_me/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamilton Tumenas Borges
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|