Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Countries ISO codes


piernas

Recommended Posts

Posted

I need to get delivery country ISO code on admin. I've seen  $order->delivery['country']['iso_code_2']  it's used on several modules, but I cannot find where it's defined on admin side (the orders class does not contain it).

 

I was expecting it empty when using it on an admin page, but instead I'm getting one letter ('U' for United States, 'E' for Spain..) instead two letter codes ('US', 'ES'...)

 

I cannot find where the property is defined. Anyone knows? :wacko:

Posted

It's in the database. Take a look at the file oscommerce.sql, which is the initial load of the database.

Posted

@@MrPhil I meant where in the code is defined $order->delivery['country']['iso_code_2'] for returning the ISO code from database.

 

I found it on the shop side of the orders class, and it's used by a lot of payment modules; however, I cannot find it on admin side - sigh!- orders class is not the same there.

 

The thing is, I can even ask for $order->delivery['country']['iso_code_725'] or $order->delivery['country']['some_strange_text'] and it will also reply with the first letter of $order->delivery['country'] base property!!!

 

It must be a php behavior I don't know. I was supposing it would return an empty string. Anyone knows why? I'm really curious now.

Posted

UPDATE: Digging a bit more I found the store side class uses tep_get countries function from general.php. Funny thing, the fucnction also exists on admin side but it's a reduced version that does not return ISO codes.... I'll have to add a custom function to the module.

 

From what I've read 2.4 will share classes and functions on all oscommerce, that will avoid these situations of duplicate/outdated code on both sides.

 

PS I'm still curious on why $order->delivery['country']['some_strange_text'] returns one single letter :)

Posted

Hi - the admin orders class works solely from the orders and orders_products table (whereas the catalog one does wonderful things :-)) - what you are seeing is just php looking at your input:

 

$order->delivery['country']['iso_code_2']

 

scratches its head a bit and decides that as it cannot find iso_code_2 in the class it'll fire off a warning

llegal string offset 'iso_code_2' 

but then being a smarty pants substitute zero (effectively) so your request is views as

 

$order->delivery['country'][0]

 

Bosh! You get the first letter in the country name.....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...