solidus icon indicating copy to clipboard operation
solidus copied to clipboard

Fix the country/state handling

Open elia opened this issue 5 years ago • 1 comments

Is your feature request related to a problem? Please describe.

This is an umbrella issue on top of:

  • https://github.com/solidusio/solidus/issues/1378
  • https://github.com/solidusio/solidus/issues/3670
  • https://github.com/solidusio/solidus/pull/3722
  • https://github.com/solidusio/solidus/pull/3807
  • https://github.com/solidusio/solidus/issues/3803

After some research seems that in ISO terms, what Solidus is trying to map is subdivisions as defined in ISO-3166-2 (https://en.wikipedia.org/wiki/ISO_3166-2, https://www.iso.org/iso-3166-country-codes.html#2012_iso3166-2).

As clearly noticed by some of the issues the term state is not right for most countries. In addition to that the way we're fetching data from Carmen might not match the correct subdivision level, or we might be requiring a "state" presence when we shouldn't.

Describe the solution you'd like

A path forward for this would be to fix the data generation basing it on the subdivisions as defined in ISO 3166-2 and maybe err on the side of not requiring the field presence unless we're 100% sure it's the right thing.

With time the database column should probably be migrated to a name that's more generic, like "subdivision" or "principal_subdivision".

A way of obtaining a list of all subdivisions should be found within Carmen (maybe contributing it back) or elsewhere. In the latter case the best candidate seems to be the iso-codes Debian package (https://salsa.debian.org/iso-codes-team/iso-codes/).

Describe alternatives you've considered

I had a look at existing gems referring to ISO-3166, none of them seem reassuringly maintained or with the data we need, best bet would be to add that into Carmen itself, given its popularity.

Additional context

On a similar topic would be great to have a pluggable system of address-validation with a storage that's enough generic to cover all the address variations of the world, possibly removing altogether the countries and states tables, delegating the whole thing outside of Solidus.

elia avatar Nov 13 '20 16:11 elia

Related: https://github.com/countries/countries

elia avatar Nov 07 '22 12:11 elia