If this is your first visit, check our documentation. To post, register or login.
Forums / Zen Cart Code Suggestions / Countries ID number

Countries ID number

Started by torvista on 17 Feb 2016, 10:27 PM · Views: 124

Results 1 to 9 of 9
17 Feb 2016, 10:27 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Countries ID number

I'm modifying a payment module where the gateway returns a number country code for where the card was issued as per:
http://unstats.un.org/unsd/methods/m49/m49alpha.htm.

I imagine that is something other gateways use (??) and so why not have that number in the countries table...why not use the countries_id as this number?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

18 Feb 2016, 12:24 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Countries ID number

Only comment(s) I have on that proposal is:

  1. What is the basis for the returned number regarding "consistency" across such applications.
  2. What impact would there be in using the currently existing country_id number in relation to existing application(s), store (would the country_ids need to be resequenced to support this and would/could there not be an impact on other tables either of the base zc or other plugins)?
  3. My suggestion if there is no "standard" for the number by any organization would be to have an additional cross reference table of "company" to country(ies).
  4. If there is a "standard" then simply a field added to the countries table to account for the relationship of this number to existing country(ies).
  5. Somewhere need to track/identify which application(s) need to use what aspect of the countries data.

Reason/basis for the above is my understanding that the countries are not currently added based on a designated number but by next record. I'd gladly be wrong. But if the order/number is different among installations, additions, removals, then that aspect would be suggested to review and contend with.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Feb 2016, 10:24 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Countries ID number

1) What is the basis for the returned number regarding "consistency" across such applications.
Not sure I understand what you mean. But the returned number-country is based on that UN table so should be a universal number.

2) What impact would there be in using the currently existing countries_id number in relation to existing application(s), store (would the country_ids need to be resequenced to support this and would/could there not be an impact on other tables either of the base zc or other plugins)?
Yes the install SQL would need to be modified and the countries_id not auto increment. Mods that reference the existing country numbers would need to be corrected (I have such mods but that's no big deal to change a few numbers).
But I think that highlights the need for a change, in that the current countries_id is subject to user changes/deletions additions in the table when they really should be fixed, to ensure mod portability at least.
I deleted many countries with 138, then reinstated the lot when lat9 did the selectable country mod. Others will have done similar so the current implementation of countries_id will vary between databases.
3) My suggestion if there is no "standard" for the number by any organization would be to have an additional cross reference table of "company" to country(ies).
I understand from the UN table that there is a standard, hence my suggestion to adopt it.
Not sure what you mean by "company"
4) If there is a "standard" then simply a field added to the countries table to account for the relationship of this number to existing country(ies).
I would just use the existing countries_id, not auto increment. But I have not invested much time in thinking over the ramifications.
5) Somewhere need to track/identify which application(s) need to use what aspect of the countries data.
Don't understand this aspect.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

18 Feb 2016, 12:01 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Countries ID number

So to try to clarify, first I'm approaching this from a limited perspective and primariily considering what might be involved.

Regarding item 1. In the OP it was described that some payment "processers" are returning a country code. So the question is if two or more such processers were sent the same information from the same location would they always return the same number? Do they all use the same "list"? I further mean and thought I had seen discussion at least related to say shipping that ZC on occasion addresses more "refined" information than what is provided at any one single source. Therefore, one could be led to assume that other businesses may do the same in order to provide a better product as well... It is these nuances that can have an impact and need to be addressed/dealt with. But if all such businesses use the same source of information, then the path forward becomes simpler. (Good luck, standardization among multiple groups is always difficult.)

Item 2 (minor further discussion), seeing as ZC does generally approach forward change with consideration of past compatibility, whatever solution is developed for a way forward is likely to need consideration against existing systems to some backwards compatibility standpoint. Wouldn't necessarily think all the way back to say ZC 1.3.7 or beyond, but... So. Therefore whatever "solution" is likely developed would probably take that into consideration and as a database driven application there appear to be two ways: either redefine the existing numbering, or provide a cross reference to the "standard".

Regarding three: company being the payment "processer" that is returning the number associated with the country. And regarding "standard" like discussed in reply of item 1) that there may be countries that exist (or no longer do) perhaps in advance of the described UN list and there may be reasons by ZC or payment "processers" to identify some place outside of that list which only complicates some things. Further didn't think of the possibility that said "number" may contain letters to sub-divide a locality...

Item 4) regarding the response... This is one reason I added my 2 cents worth. Seems like a good idea brewing, get others onboard with the discussion, begin looking at how to implement and a solution ought to fall out... ZC is a community, not a set of a few developers forcing everything to be this or that way... Change can be made with the information sought out and "centrally" located.

Item 5) doesn't seem that all payment "processers" use/return such a country number, therefore the process to use/expect that information needs to be tempered to not require that information unless there is yet some other unknown by me requirement... It's pretty much an understood condition, but sometimes the obvious things are not so obvious. :) point being that if payment "processer" X is expected to provide a country code, shouldn't ZC identify when that country code is not provided? Seems to be just one more part of ensuring financial security of the operation of the software...

Hope that all helps clarify... There's been some "homework" done which is good. Furthering that research will only strengthen the path forward. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

19 Jun 2016, 10:57 AM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Countries ID number

Bumping this.

To rephrase the OP and get to the point,
irrespective of the use, in an ideal world would it not be correct to have the countries table using a countries_id as defined and maintained by ISO:
https://en.wikipedia.org/wiki/ISO_3166-1_numeric
instead of the arbitrary id it uses now.

Why?

  1. It seems the correct thing to do.
  2. mods offering localized functionality become properly portable.

I am revamping my site/looking at my hacks involving countries_id and thinking at doing this...converting existing customer records seems the only real bugbear.

Apart from backwards compatibility, is there some problem with implementing this: just changing all the current countries_id to ISO ones?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

19 Jun 2016, 11:32 AM
#6
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Countries ID number

I was toying with the same idea, as I am busy with the multi lingual country names (included in Zen Cart 1.6).
For existing records you would not only need to update your customer tables, but also orders, address book, zones , payment methods, shipping method, tax rules, may be more. So it is not an simple task, but also not undo-able.
Instead of using the id, may be it is easier to use the 2 or 3 letter iso code. Or add an extra column in the table with the iso id number

19 Jun 2016, 1:36 PM
#7
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Countries ID number

Instead of using the id, may be it is easier to use the 2 or 3 letter iso code. Or add an extra column in the table with the iso id number
That's the conclusion I came to while mopping the kitchen.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

19 Jun 2016, 9:27 PM
#8
vdecals avatar

vdecals

Zen Follower

Join Date:
Jun 2009
Location:
Sparta, TN
Posts:
166
Plugin Contributions:
0

Re: Countries ID number

mc12345678:

..
Item 4) regarding the response... This is one reason I added my 2 cents worth. Seems like a good idea brewing, get others onboard with the discussion, begin looking at how to implement and a solution ought to fall out... ZC is a community, not a set of a few developers forcing everything to be this or that way... Change can be made with the information sought out and "centrally" located.
...
And @torvista and Design75 got to looking at specific countries that will be cleaned-up in 1.6.0
https://www.zen-cart.com/showthread.php?220480-Countries-minor-changes-and-missing-entries
Thank you all! :hug:

My store - closed 12/05/2023
1.5.7d (upgraded from 1.5.7b), clone a template (cloned Responsive Classic Template), Sitemap XML v4.0, Square WebPay, PayPal Express Checkout, PHP Version: 7.4.29 (Zend: 3.4.0)

20 Jun 2016, 12:14 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Countries ID number

torvista:

Apart from backwards compatibility, is there some problem with implementing this: just changing all the current countries_id to ISO ones?
You'll have a HUGE backward compatibility issue.

I would reject a PR which makes a change to countries_id. That would break a million things and make upgrading a nightmare.

But I have no objection to adding an iso_country_number field for those who might need it. (Granted, I've never seen anybody ask for that value to be present.)

I also support the reworking of PHP code to rely on the 3-letter-ISO code as the primary lookup throughout the application, especially if it comes with automated tests to ensure reliability.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.