I've backported a previously submitted patch #317758: Map country names in USPS from ISO-3166 to USPS value - ex: 'Korea, Republic of' and "Great Britain" to work with the 5.x branch. In addition to the backported code, I've added mapping for all resolvable ISO country codes.
Some things to note: I used values from the USPS International Rate Calculator website, not the page listed in the USPS API documentation. I've found the latter to be inaccurate when testing against the API.
I've performed an ad-hoc unit-test against the API with the 102 countries that our store is configured with, and all have passed. By "passed" I mean that the country name passed in the request was recognized as valid by the API. In some cases there were unrelated errors returned (e.g. "At this time, all mail services to Somalia are either suspended or not available"). Attached are the unit-test results.
We'll be deploying this patch for our live store today, so this should improve the test coverage—there are already people in Turkey and South Korea waiting to order stuff, w00t!
| Comment | File | Size | Author |
|---|---|---|---|
| usps-country-map-tests.txt | 5.79 KB | marxarelli | |
| 317758_uc_usps_country_names-5.x.patch | 8.5 KB | marxarelli |
Comments
Comment #1
marxarelli commentedWhoops, I didn't read the handbook.
Comment #2
marxarelli commentedI forgot to mention two things:
Comment #3
tr commentedYour function uc_usps_country_map() should contain *only* the countries that need to have a different name for USPS. That is how the D6 patch works (http://drupal.org/node/317758#comment-2028100). It looks like you're mapping *all* the country names, even when the name is the same. Also, you need to include the other fix from http://drupal.org/node/609444#comment-2201040.
Comment #4
marxarelli commentedSorry for the late reply.
I disagree with your approach to the mapping, in that it's not a good approach to rely on the country names in
{uc_countries}. That data is mutable in the event a user imports a custom CIF. The only reliable identifiers from which to map are the ones based on standards: the ISO 3166-1 alpha or numeric codes.To say that the code is a waste because it doesn't do anything—you didn't make this claim, but the commenter you referenced did—is to assume that the country data will not be reconfigured, when in fact the opposite should be assumed expressly because it is made configurable through the admin UI.
Not to sound like a douche, but I've worked a lot with mapping of data between web services in the past and the method I used has always proved more robust—I failed, that sure is a douche-y word.
Comment #5
longwaveIt's too late to do anything with this now Drupal 5 is obsolete.