shipperhq / module-address-autocomplete

ShipperHQ Address Autocomplete for Magento 2
Open Software License 3.0
15 stars 20 forks source link

Turn address #11

Closed DylanStruik closed 2 years ago

DylanStruik commented 6 years ago

In the Netherlands, our address format is like this:

Robijnstraat (street) 11 (housenumber)

When I fill in this address in your plugin, the output is like this:

11 Robijnstraat

Is it possible to add an option for Netherlands addresses?

TravisBernard commented 6 years ago

Hi @DylanStruik thanks for reporting this. I think it could be a really nice feature, we'll have to see what we can realistically do here though.

How do you imagine setting this up on the stores side will look? Should the address format be defined by the merchant? Should we make our best guess at format to use (keeping address formats for every locale is a lot of work)? Would setting one format for each store be sufficient for stores that ship internationally?

As you can see it can get very complicated very fast. I'll raise this with our team but your feedback here is welcome.

DylanStruik commented 6 years ago

Hi @TravisBernard,

For now {streetname} {housenumber} would fit my needs. Is it possible that I edit the code a little bit so this could be achieved? Can you tell me which files and lines I've to edit?

Maybe another solution could be to put the {housenumber} in another input field. This would solve the problem for all countries.

Thanks for your time.

Kind regards,

Dylan

TravisBernard commented 6 years ago

Hi @DylanStruik we have a tentative solution for this problem internally but it hasn't landed in a sprint yet - so coming soon but no ETA. Please don't edit the contents of the ShipperHQ modules directly as your changes will be lost when you composer update. That said if you need a workaround today you can do so using one of Magento's plugin/mixin options and your own small module.

To help you get this resolved, our tentative plan is to edit src/view/frontend/web/js/autocomplete.js lines 80-115. These lines parse the autocomplete response from Google and assign it into fields. Our thought is to use the place.adr_address field from the Google response as our cue about the proper format for the user's locale. In the example address you gave you'll see that adr_address lists the street before the building. We haven't researched yet how accurate this is in other locales though.

If you would like to submit a pull request we'd gladly accept it (although we currently do our development on another repository so the commit wont show contribution for you, sorry ☹️ ). Otherwise please create your own module and use a JS Mixin to overwrite the functionality.

wsajosh commented 2 years ago

We've added support for this in 20.6.0. Thanks for the suggestion!