Moqui / PopCommerce: country-specific postal address format profiles? - moqui

I'm totally new to Moqui/PopCommerce and my first impressions of it are great.
One thing that I didn't find how to do was country-specific postal address formatting: unfortunately, every country has a different address format, with different fields, ordering and arrangement of the fields.
For example, in most of Europe, the Zip code is expected left of the city name and there is no '#' sign in front of the house number. In France, the house number is left of the street and followed by a comma.
Some countries e.g. in Asia even have multiple address formats depending on other factors (e.g. rural vs city)
You can see explanations and examples here:
https://en.wikipedia.org/wiki/Address_(geography)#Format_by_country
http://www.columbia.edu/~fdc/postal/
So for any software that handles postal addresses, there are at least two situations where that country-specific address formatting is relevant:
1. in any output of a postal address (e.g. display, printout, mail, pdf, etc.)
2. in input of a postal address (e.g. address input form)
While an input form that doesn't adapt to the country-specific format is only a secondary problem (at least as long as it is only used by internal users and not external customers), any address output (especially one that is seen by any external customers) really HAS to conform to the country-specific address format and order, which means that there should be some way in the input form to choose an address format profile (e.g. by adapting to the chosen country).
I didn't see how to do that easily. I did find a PostalAddressSimpleTemplate variable in /vapps/system/Localization , but as I understand it, adding translations there would make the output dependent on the locale chosen by the user and not on the country of the address.
So my questions are:
* Is there any easy way to do this? (maybe I just didn't find it?)
* If not, is this something that would likely be added in the near future?

To date the functionality in SimpleScreens (which is where the postal address entry forms and display templates are located) is more USA oriented because all of the sponsorship for it has been by companies in the USA. There have been a few contributions that are localization related, and a few localization components that others have built (see the Add Ons page on moqui.org), but these particular forms seem to be customized rather than made more dynamic to work better across a wider variety of locales.
If you are targeting a specific locale the best thing to do is plugin your own address entry form and display template, and if you are building a public facing web site you probably shouldn't use the forms or templates from SimpleScreens anyway (all are meant for internal applications, or portal sorts of sites for external users with a limited scope, but really not for ecommerce and other sorts of sites where they are publicly available and users won't use them enough to be able to use them with no training or documentation, or from another point of view benefit from the standard UI patterns).
The OOTB input form has started to move in a more country-generic direction with the country drop-down being to the left of the state/province drop-down (for whatever sub-country region is used in the country) and the state/province drop-down reloads from the server when the country is changed.
The output structure (in the address .gstring file, for HTML output) doesn't currently do anything different based on the country.
These will both change over time, but right now basically to handle country-specific input forms or output templates customization is required.

Related

How can I determine the IANA timezone of a specific location

Is there a (free) webservice where I can a) give it an address (either full or city, state/province and zip), and b) get the IANA timezone of that address?
Use case: I have a form where a user manages clinics. Each clinic has an address. I want to preselect that IANA timezone of that address, so that I can adjust appointment date/times associated with that clinic.
I know that the Google Maps API and Bing Maps API can give me the lat/long of an address, and that there are other services that can give me the IANA TZ based on the lat/long. That said, those api's require subscriptions and keys and contracts, and it would also require a two request approach to get the single piece of data.
Address geolocation is a hard problem. It requires deep understanding of address systems and reacting to ever-changing, real-world, messy scenarios.
For example, you could get a database of the Zip codes of the United States and their approximate locations, but it would only be a snapshot. You'd find over time that new Zip codes would be added and missing from your data, and that existing Zip codes had been expanded to include other areas. You'd also find many Zip codes that are "non-locatable", such as those used to send mail to military overseas. You could even find a single Zip code that has addresses in two different time zones.
Take international concerns into effect and you'll find all sorts of edge cases. Every country and territory has their own special rules and situations.
It is a problem worth paying a service provider for. Trying to do geolocation in an offline manner might be possible, but it isn't advised.
The second part - figuring out which time zone goes to a location, is also messy. However it's slightly easier to coordinate. The Time Zone Boundary Builder is the main open-source project that attempts this. Most libraries referenced here use that data. But even then, it has updates and relies on borders established by Open Street Map data. Some of those borders are in dispute, so a service from Google, Microsoft, or others could give different results because they have map data with different borders. If you care about such things then you might want to test some edge cases against the different providers to see if you're satisfied with the results. You may find that the TZBB data works well, or you might prefer one of the online solutions.

In magento 2, zip code text box to search the store available or not

I am new to Magento.
I want a text box where i can type the zip code and if the store available in that location then i need to show the products of that particular store otherwise we need to show that "the store is not available in particular location".
The following is the example site. i want it as it is.
this site prompts for users zip location .after it will display stores of that particular.
Click on this link to see the working example
how do i do this . Do i need to install a module ?
Follow Some Steps:
You need an entity 'store' that is bound to a geo location.
You need to create a multi select attribute which values are located (using a
source model) with these stores. This way, you can attach a single product to
multiple stores (one to many relation)
Then you need some sort of external API to convert a postcode entered by the
customer to a geo location. I assume the Google Maps API can do this. It would
be best to handle this server side.
Then you need the math to calculate the distance between 2 geo locations in
your database query (probably enough to find on that subject on Google) and
filter your product collection on that.
Once you have the collection you have the power.
The external API will probably have a request threshold so you might have to
pay for that (depending on the traffic).
You need to determine the radius of maximum distance between 2 geo locations.
In a small country like the Netherlands stores could be a couple of km's apart
from each other, whilst in the United States it's not uncommon to have stores
tens or hundreds of km's from each other.
**Best Of Luck For Your Project**

Vies database split address

I'm using vatlayer API for getting company information by put in the vat number. https://vatlayer.com/documentation
Now I want split address info in the state, zipcode, addressline and address number.
I get the address info: BREDABAAN 13052900 SCHOTEN.
The address number and zipcode stands against each other without spacing. (1305number and 2900 zipcode).
Is there another API for working with the vies database where i can split these information? Or an work around for this bug?
VatLayer don't support the split atm.
I get the address information by:
$("#organisation_address_line_1").val(json.company_address);
Thanks in advance,
There's quite a lot of API's to handle VAT validation but the ones that provide information about the trader essentially all rely on the official API at http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl . It connects directly to the VIES system. Perhaps the values returned there are a bit different: it's worth trying your validation that way as well.
Unfortunately, since VIES does not return structured addresses (except for approximate matches, but only Spain supports them at the moment) and does not specify a common format for the free text addresses, you're going to have to deal with whatever format the country has chosen to provide, which means manual parsing.
I reckon 3rd party wrapping API's could handle guessing the format and splitting the formats on their own but I am not aware of any that would do it.

Google Maps Place Result how to translate into multiple languages

I use the Places Autocomplete Service to search for a specific address. The Adress should be stored to database on my model to know where it is located. My site is multi lingual and I have to print the adress (e.g. the country names) in the choosen language. Also I have to filter the models by country or city's name.
Is there a way to get the PlaceResult in multiple languages?
I use the Javascript API in the version v3.8

How to validate a location address in form?

I want to validate that the postal address filled in by a user is correct.
Assuming that we have the fields street, street_number, postal_code, city and country
How can show errors when the user, types in that his country is France and is city is New York?
or
How can I detect that a postal code doesn't correspond to the city?
Is there a strategy to address this issue with Ruby On Rails or shall I just trust the user entries ?
There are several companies that publish US ZIP code directories, typically not terribly expensive, and some even come with lat/lon data. This is the most common way of validating city and state in the US or North America. Worldwide postal codes to country and city is likely to be a harder problem, or at least a more expensive one.
Another approach would be to use the Google Maps API, perhaps in conjunction with the data you can get from location-aware browsers (all modern ones). To be honest, it's been a while since I have used the API, but seem to recall you can get pretty detailed information given a lat/lon. Google now charges for high use of the Maps API, but if your site has even moderate traffic, you're probably still in the free zone.
At some level, you'll have to trust users. I remember a while back we found anomalies in user reported zipcodes in our database -- seemed like everyone lived in Beverly Hills, CA. This was around 2000, when the original version of the TV show "90210" was still around -- that's the zipcode :-).
Have you considered just a jQuery plugin to verify addresses for you? It's free for many users, up to 250 lookups/mo, and is always current (no need for you to maintain a database).
Incidentally, I work at SmartyStreets. There's also a ZIP code API to look up if cities match ZIP codes and vice-versa. Either way, we've put a lot of effort into making the user experience positive, even when the address they type isn't totally valid.