spree_boxnow 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -32
- data/app/lib/spree_boxnow/phone_normalizer.rb +19 -0
- data/app/services/spree_boxnow/create_voucher.rb +2 -2
- data/lib/spree_boxnow/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f62d5fc8bf2894744140e90eba7aa7c6eeeda3b45f5d2002631196747ab663e7
|
|
4
|
+
data.tar.gz: 87466f19dc78f545ec26bc3e140f53c9759fecb9a57f811853362b91b4000b69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d1b9a5368eef166ef932bb2b53e93930f57ddc911618efbd97acaec6154004fa7f870dedb86fa1a05b0fcb3e97521ab3858fd5fbcdb03ef1002d7d73d531e69
|
|
7
|
+
data.tar.gz: e641fb1f659b9c27d2275127f17144472e109c42762291aad553f49d34d0e04d9eda07be8cade5d1e126f066c4d161e1c1d8b372a6d16ef10b2d82b73f296f08
|
data/README.md
CHANGED
|
@@ -34,16 +34,16 @@ A [Spree Commerce](https://spreecommerce.org) extension that integrates **BoxNow
|
|
|
34
34
|
|
|
35
35
|
Go to **Admin → Integrations → BoxNow** and fill in:
|
|
36
36
|
|
|
37
|
-
| Field
|
|
38
|
-
|
|
39
|
-
| **Client ID**
|
|
40
|
-
| **Client Secret**
|
|
41
|
-
| **Partner ID**
|
|
42
|
-
| **API URL**
|
|
43
|
-
| **Origin Location ID** | Your warehouse/store APM location ID
|
|
44
|
-
| **Contact Name**
|
|
45
|
-
| **Contact Phone**
|
|
46
|
-
| **Contact Email**
|
|
37
|
+
| Field | Description |
|
|
38
|
+
| ---------------------- | ------------------------------------------------------------- |
|
|
39
|
+
| **Client ID** | Provided by BoxNow |
|
|
40
|
+
| **Client Secret** | Provided by BoxNow |
|
|
41
|
+
| **Partner ID** | Provided by BoxNow |
|
|
42
|
+
| **API URL** | BoxNow API base URL (e.g. `https://api-production.boxnow.gr`) |
|
|
43
|
+
| **Origin Location ID** | Your warehouse/store APM location ID |
|
|
44
|
+
| **Contact Name** | Sender contact name printed on labels |
|
|
45
|
+
| **Contact Phone** | Sender phone number |
|
|
46
|
+
| **Contact Email** | Sender email address |
|
|
47
47
|
|
|
48
48
|
OAuth2 tokens are obtained automatically using Client Credentials and cached in `Rails.cache` for 1 hour.
|
|
49
49
|
|
|
@@ -56,12 +56,12 @@ The shipping calculator determines the price tier from the physical dimensions o
|
|
|
56
56
|
|
|
57
57
|
BoxNow hard limits:
|
|
58
58
|
|
|
59
|
-
| Dimension
|
|
60
|
-
|
|
59
|
+
| Dimension | Limit |
|
|
60
|
+
| ---------- | ----- |
|
|
61
61
|
| Max weight | 20 kg |
|
|
62
62
|
| Max height | 36 cm |
|
|
63
|
-
| Max width
|
|
64
|
-
| Max depth
|
|
63
|
+
| Max width | 45 cm |
|
|
64
|
+
| Max depth | 60 cm |
|
|
65
65
|
|
|
66
66
|
### 3. Create a BoxNow shipping method
|
|
67
67
|
|
|
@@ -72,13 +72,13 @@ Go to **Admin → Shipping Methods → New**:
|
|
|
72
72
|
3. Select **BoxNow Rate** as the calculator
|
|
73
73
|
4. Set the calculator preferences:
|
|
74
74
|
|
|
75
|
-
| Preference
|
|
76
|
-
|
|
77
|
-
| **Small box price**
|
|
78
|
-
| **Medium box price**
|
|
79
|
-
| **Large box price**
|
|
80
|
-
| **Base padding (cm)** | 1.0
|
|
81
|
-
| **Multi-item factor** | 1.05
|
|
75
|
+
| Preference | Default | Description |
|
|
76
|
+
| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| **Small box price** | 0.0 | Price for parcels ≤ 8 cm in height |
|
|
78
|
+
| **Medium box price** | 0.0 | Price for parcels ≤ 17 cm in height |
|
|
79
|
+
| **Large box price** | 0.0 | Price for parcels ≤ 36 cm in height |
|
|
80
|
+
| **Base padding (cm)** | 1.0 | Added to every dimension to account for the physical box being slightly larger than its contents. Set to `0` to disable. |
|
|
81
|
+
| **Multi-item factor** | 1.05 | Multiplier applied to all dimensions when an order has more than one item (accounts for imperfect stacking). Set to `1.0` to disable. |
|
|
82
82
|
|
|
83
83
|
---
|
|
84
84
|
|
|
@@ -87,17 +87,18 @@ Go to **Admin → Shipping Methods → New**:
|
|
|
87
87
|
The calculator models the entire order as **one parcel** — there is no multi-box splitting.
|
|
88
88
|
|
|
89
89
|
For each line item it:
|
|
90
|
+
|
|
90
91
|
1. Sorts the variant's three dimensions smallest → largest (`s ≤ m ≤ d`)
|
|
91
92
|
2. Stacks items along the smallest axis: `parcel_height += s × quantity`
|
|
92
93
|
3. Takes `width = max(m)` and `depth = max(d)` across all items
|
|
93
94
|
|
|
94
95
|
After stacking, padding and the multi-item factor are applied. The resulting three dimensions are then sorted again to allow virtual rotation, and the smallest is compared against the tier thresholds.
|
|
95
96
|
|
|
96
|
-
| Tier
|
|
97
|
-
|
|
98
|
-
| Small
|
|
99
|
-
| Medium | ≤ 17 cm
|
|
100
|
-
| Large
|
|
97
|
+
| Tier | Height threshold |
|
|
98
|
+
| ------ | ---------------- |
|
|
99
|
+
| Small | ≤ 8 cm |
|
|
100
|
+
| Medium | ≤ 17 cm |
|
|
101
|
+
| Large | ≤ 36 cm |
|
|
101
102
|
|
|
102
103
|
If the package exceeds the large threshold or any hard limit, `nil` is returned and the BoxNow shipping option is hidden from checkout.
|
|
103
104
|
|
|
@@ -159,12 +160,12 @@ If a voucher creation attempt fails and the admin retries, the extension appends
|
|
|
159
160
|
|
|
160
161
|
## Routes
|
|
161
162
|
|
|
162
|
-
| Method | Path
|
|
163
|
-
|
|
164
|
-
| `POST` | `/boxnow/select_locker`
|
|
165
|
-
| `POST` | `/{admin_path}/boxnow/:order_id/create`
|
|
166
|
-
| `GET`
|
|
167
|
-
| `POST` | `/{admin_path}/boxnow/:order_id/cancel`
|
|
163
|
+
| Method | Path | Action |
|
|
164
|
+
| ------ | ---------------------------------------------- | ------------------------------------------------- |
|
|
165
|
+
| `POST` | `/boxnow/select_locker` | Storefront: save locker selection |
|
|
166
|
+
| `POST` | `/{admin_path}/boxnow/:order_id/create` | Admin: create voucher |
|
|
167
|
+
| `GET` | `/{admin_path}/boxnow/:order_id/print` | Admin: print/download voucher PDF |
|
|
168
|
+
| `POST` | `/{admin_path}/boxnow/:order_id/cancel` | Admin: cancel voucher |
|
|
168
169
|
| `POST` | `/{admin_path}/boxnow/:order_id/select_locker` | Admin: update locker selection (pre-voucher only) |
|
|
169
170
|
|
|
170
171
|
---
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'phonelib'
|
|
2
|
+
|
|
3
|
+
module SpreeBoxnow
|
|
4
|
+
# Normalizes phone numbers to the full international (E.164) format BoxNow
|
|
5
|
+
# requires, e.g. +306912345678. `country_iso` is the ISO 3166-1 alpha-2
|
|
6
|
+
# code used to interpret a number given in national format (defaults to
|
|
7
|
+
# GR, since BoxNow only operates in Greece); numbers already given in
|
|
8
|
+
# international format (leading +) are parsed as-is regardless.
|
|
9
|
+
module PhoneNormalizer
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def call(phone, country_iso = nil)
|
|
13
|
+
return '' if phone.blank?
|
|
14
|
+
|
|
15
|
+
parsed = Phonelib.parse(phone, country_iso || 'GR')
|
|
16
|
+
parsed.valid? ? parsed.e164 : phone.to_s
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -31,13 +31,13 @@ module SpreeBoxnow
|
|
|
31
31
|
origin: {
|
|
32
32
|
locationId: integration.preferred_origin_location_id,
|
|
33
33
|
contactName: integration.preferred_contact_name.presence || '',
|
|
34
|
-
contactNumber: integration.preferred_contact_phone
|
|
34
|
+
contactNumber: PhoneNormalizer.call(integration.preferred_contact_phone),
|
|
35
35
|
contactEmail: integration.preferred_contact_email.presence || ''
|
|
36
36
|
},
|
|
37
37
|
destination: {
|
|
38
38
|
locationId: destination_id,
|
|
39
39
|
contactName: address.full_name,
|
|
40
|
-
contactNumber: address.phone.
|
|
40
|
+
contactNumber: PhoneNormalizer.call(address.phone, address.country_iso),
|
|
41
41
|
contactEmail: order.email.to_s
|
|
42
42
|
},
|
|
43
43
|
items: [{
|
data/lib/spree_boxnow/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_boxnow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OlympusOne
|
|
@@ -107,6 +107,20 @@ dependencies:
|
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
109
|
version: '2.0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: phonelib
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0.10'
|
|
117
|
+
type: :runtime
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0.10'
|
|
110
124
|
- !ruby/object:Gem::Dependency
|
|
111
125
|
name: spree_dev_tools
|
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +150,7 @@ files:
|
|
|
136
150
|
- app/javascript/spree_boxnow/application.js
|
|
137
151
|
- app/javascript/spree_boxnow/controllers/spree_boxnow_controller.js
|
|
138
152
|
- app/lib/spree_boxnow/api_client.rb
|
|
153
|
+
- app/lib/spree_boxnow/phone_normalizer.rb
|
|
139
154
|
- app/models/spree/calculator/shipping/boxnow_rate.rb
|
|
140
155
|
- app/models/spree/integrations/boxnow.rb
|
|
141
156
|
- app/models/spree/order_decorator.rb
|
|
@@ -167,10 +182,10 @@ licenses:
|
|
|
167
182
|
- MIT
|
|
168
183
|
metadata:
|
|
169
184
|
bug_tracker_uri: https://github.com/olympusone/spree_boxnow/issues
|
|
170
|
-
changelog_uri: https://github.com/olympusone/spree_boxnow/releases/tag/v1.
|
|
185
|
+
changelog_uri: https://github.com/olympusone/spree_boxnow/releases/tag/v1.2.0
|
|
171
186
|
documentation_uri: https://github.com/olympusone/spree_boxnow
|
|
172
187
|
homepage_uri: https://github.com/olympusone/spree_boxnow
|
|
173
|
-
source_code_uri: https://github.com/olympusone/spree_boxnow/tree/v1.
|
|
188
|
+
source_code_uri: https://github.com/olympusone/spree_boxnow/tree/v1.2.0
|
|
174
189
|
rdoc_options: []
|
|
175
190
|
require_paths:
|
|
176
191
|
- lib
|