Skip to content

Commit

Permalink
20.6.2 SHQ23-326 Fix issue with formatting of US addresses containing…
Browse files Browse the repository at this point in the history
… an apartment or suite number
  • Loading branch information
wsajosh committed Apr 13, 2023
1 parent d6ac2f1 commit 42dcbb2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.MD
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ MNB-574 Add support for placing house number after street name
MNB-2364 Resolve issue with Montreal not being populated as city


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


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ MNB-574 Add support for placing house number after street name
MNB-2364 Resolve issue with Montreal not being populated as city


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


20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,25 @@ You will need a Google API key that has been enabled with “Google Places API W

Compatibility
-------------
- Magento >= 2.3
This module supports and is tested against the following Magento versions:

* 2.4.5-p1
* 2.4.5
* 2.4.4-p2
* 2.4.4-p1
* 2.4.4
* 2.4.3-p3
* 2.4.3-p2
* 2.4.3
* 2.4.2
* 2.4.1
* 2.4.0

per the [official Magento 2 requirements](https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html)

Supports both Magento Opensource (Community) and Magento Commerce (Enterprise)

Compatibility with earlier editions is possible but not maintained.

Installation Instructions
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-address-autocomplete",
"description": "ShipperHQ Address Autocomplete Tool",
"type": "magento2-module",
"version": "20.6.1",
"version": "20.6.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-address-autocomplete",
"description": "ShipperHQ Address Autocomplete Tool",
"type": "magento2-module",
"version": "20.3.0",
"version": "20.6.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
19 changes: 16 additions & 3 deletions src/view/frontend/web/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,17 @@ define(
var city = '';
var postcode = '';
var postcodeSuffix = '';
var subpremise = ''; // This is apartment/unit/flat number etc
var countryId = '';

for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[addressType]) {
var value = place.address_components[i][componentForm[addressType]];
if (addressType === 'subpremise') {
streetNumber = value + '/';
subpremise = value;
} else if (addressType === 'street_number') {
streetNumber = streetNumber + value;
streetNumber = value;
} else if (addressType === 'route') {
street[1] = value;
} else if (addressType === 'administrative_area_level_1') {
Expand Down Expand Up @@ -161,13 +163,19 @@ define(
}

if (elementId === 'country_id') {
numberAfterStreet = numberAfterStreetCountries.includes(value);
countryId = value;
numberAfterStreet = numberAfterStreetCountries.includes(countryId);
}
}
}//end if
}//end if
}//end for

// SHQ23-326 US Address Format is street address, unit or apartment number
if (subpremise.length > 0 && countryId !== 'US') {
streetNumber = subpremise + '/' + streetNumber;
}

if (street.length > 0) {
if (numberAfterStreet) {
street[0] = street[1];
Expand All @@ -178,6 +186,11 @@ define(

var domID = uiRegistry.get('checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset.street').elems()[0].uid;
var streetString = street.join(' ');

if (countryId === 'US') {
streetString += ', ' + subpremise
}

if ($('#' + domID).length) {
$('#' + domID).val(streetString);
$('#' + domID).trigger('change');
Expand Down

0 comments on commit 42dcbb2

Please sign in to comment.