diff --git a/CHANGELOG-PUBLIC.MD b/CHANGELOG-PUBLIC.MD index cd1c98b..44c5f22 100644 --- a/CHANGELOG-PUBLIC.MD +++ b/CHANGELOG-PUBLIC.MD @@ -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 + + diff --git a/CHANGELOG.MD b/CHANGELOG.MD index cd1c98b..44c5f22 100755 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -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 + + diff --git a/README.md b/README.md index 0c0d587..537fab8 100644 --- a/README.md +++ b/README.md @@ -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 ------------------------- diff --git a/composer.json b/composer.json index 85ba6a7..41d6862 100755 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/composer.json b/src/composer.json index 0bfe6eb..a19dd16 100755 --- a/src/composer.json +++ b/src/composer.json @@ -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" diff --git a/src/view/frontend/web/js/autocomplete.js b/src/view/frontend/web/js/autocomplete.js index 9b12a9e..97040af 100644 --- a/src/view/frontend/web/js/autocomplete.js +++ b/src/view/frontend/web/js/autocomplete.js @@ -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') { @@ -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]; @@ -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');