Add a service for resolving a US state from a given Zip code

Created on 13 June 2024, 12 days ago
Updated 14 June 2024, 12 days ago

When issue 147 on GitHub was resolved, it removed all postal code patterns from the data set. The contention at the time was that this was an unnecessary validation step the module didn't really need to concern itself with, but by removing the data entirely, we also lost the ability to take just a Zip code from a customer and derive the state from that input for the sake of Commerce Cart Estimate β†’ features.

We could add a resolver to that module itself, but I wonder if we shouldn't be doing that within the Address module. I'm not suggesting we go back to validating a given postal code against a selected administrative area, but having the data and the ability to say, "We think 29601 is South Carolina in the US" is a useful utility.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rszrama

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rszrama
  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    It appears we'd essentially want to create a script in this module (or another) that scrapes https://chromium-i18n.appspot.com/ssl-address to fetch country subdivision level postal code patterns for reference.

  • πŸ‡·πŸ‡ΈSerbia bojanz

    I think it's nice for Address to have a US-specific service that takes a postal code and returns an administrative area. That service can then hardcode the data it needs (the postal code prefixes that are matched against).

    Would it make sense to call it a locator? \Drupal\address\Locator\UnitedStates? I'll let you and Jonathan bikeshed that.

Production build 0.69.0 2024