Skip to content

Commit 42dcbb2

Browse files
committed
20.6.2 SHQ23-326 Fix issue with formatting of US addresses containing an apartment or suite number
1 parent d6ac2f1 commit 42dcbb2

File tree

6 files changed

+45
-6
lines changed

6 files changed

+45
-6
lines changed

CHANGELOG-PUBLIC.MD

+4
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ MNB-574 Add support for placing house number after street name
7777
MNB-2364 Resolve issue with Montreal not being populated as city
7878

7979

80+
## 20.6.2 (2023-04-13)
81+
SHQ23-326 Fix issue with formatting of US addresses containing an apartment or suite number
82+
83+

CHANGELOG.MD

+4
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ MNB-574 Add support for placing house number after street name
7777
MNB-2364 Resolve issue with Montreal not being populated as city
7878

7979

80+
## 20.6.2 (2023-04-13)
81+
SHQ23-326 Fix issue with formatting of US addresses containing an apartment or suite number
82+
83+

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@ You will need a Google API key that has been enabled with “Google Places API W
2121

2222
Compatibility
2323
-------------
24-
- Magento >= 2.3
24+
This module supports and is tested against the following Magento versions:
25+
26+
* 2.4.5-p1
27+
* 2.4.5
28+
* 2.4.4-p2
29+
* 2.4.4-p1
30+
* 2.4.4
31+
* 2.4.3-p3
32+
* 2.4.3-p2
33+
* 2.4.3
34+
* 2.4.2
35+
* 2.4.1
36+
* 2.4.0
37+
38+
per the [official Magento 2 requirements](https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html)
39+
40+
Supports both Magento Opensource (Community) and Magento Commerce (Enterprise)
41+
42+
Compatibility with earlier editions is possible but not maintained.
2543

2644
Installation Instructions
2745
-------------------------

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shipperhq/module-address-autocomplete",
33
"description": "ShipperHQ Address Autocomplete Tool",
44
"type": "magento2-module",
5-
"version": "20.6.1",
5+
"version": "20.6.2",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

src/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shipperhq/module-address-autocomplete",
33
"description": "ShipperHQ Address Autocomplete Tool",
44
"type": "magento2-module",
5-
"version": "20.3.0",
5+
"version": "20.6.2",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

src/view/frontend/web/js/autocomplete.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,17 @@ define(
116116
var city = '';
117117
var postcode = '';
118118
var postcodeSuffix = '';
119+
var subpremise = ''; // This is apartment/unit/flat number etc
120+
var countryId = '';
119121

120122
for (var i = 0; i < place.address_components.length; i++) {
121123
var addressType = place.address_components[i].types[0];
122124
if (componentForm[addressType]) {
123125
var value = place.address_components[i][componentForm[addressType]];
124126
if (addressType === 'subpremise') {
125-
streetNumber = value + '/';
127+
subpremise = value;
126128
} else if (addressType === 'street_number') {
127-
streetNumber = streetNumber + value;
129+
streetNumber = value;
128130
} else if (addressType === 'route') {
129131
street[1] = value;
130132
} else if (addressType === 'administrative_area_level_1') {
@@ -161,13 +163,19 @@ define(
161163
}
162164

163165
if (elementId === 'country_id') {
164-
numberAfterStreet = numberAfterStreetCountries.includes(value);
166+
countryId = value;
167+
numberAfterStreet = numberAfterStreetCountries.includes(countryId);
165168
}
166169
}
167170
}//end if
168171
}//end if
169172
}//end for
170173

174+
// SHQ23-326 US Address Format is street address, unit or apartment number
175+
if (subpremise.length > 0 && countryId !== 'US') {
176+
streetNumber = subpremise + '/' + streetNumber;
177+
}
178+
171179
if (street.length > 0) {
172180
if (numberAfterStreet) {
173181
street[0] = street[1];
@@ -178,6 +186,11 @@ define(
178186

179187
var domID = uiRegistry.get('checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset.street').elems()[0].uid;
180188
var streetString = street.join(' ');
189+
190+
if (countryId === 'US') {
191+
streetString += ', ' + subpremise
192+
}
193+
181194
if ($('#' + domID).length) {
182195
$('#' + domID).val(streetString);
183196
$('#' + domID).trigger('change');

0 commit comments

Comments
 (0)