Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    364
    Plugin Contributions
    0

    Default Change State to use ISO Codes

    I need to change our store to use the ISO US State codes instead of the complete spelling of the State.

    The address book-drop down doesn't matter either way, I just need the ISO codes to be in the final order info!

    Our order fulfillment software uses the ISO codes and chokes when importing the full spelling of the States.

    Thanks
    Experience is what you get when you don’t get what you want…

  2. #2
    Join Date
    Mar 2008
    Location
    Cape Town & London (depends on the season)
    Posts
    2,975
    Plugin Contributions
    0

    Default Re: Change State to use ISO Codes

    If you are familiar with phpMyAdmin, you could do this:

    BACKUP YOUR DATABASE FIRST!

    Log into phpMyAdmin and open the relevant database

    Navigate to the zones table (left-hand menu) and click on the ICON in that menu (not the word).

    Click EXPORT at the top of the screen.

    When the export options come up, make sure to select UPDATE as the export type.

    It will return a list something like this (I show the first two lines)
    Code:
    UPDATE `zones` SET `zone_id` = 1,`zone_country_id` = 223,`zone_code` = 'AL',`zone_name` = 'Alabama' WHERE  `zones`.`zone_id` = 1;
    UPDATE `zones` SET `zone_id` = 2,`zone_country_id` = 223,`zone_code` = 'AK',`zone_name` = 'Alaska' WHERE  `zones`.`zone_id` = 2;
    (Now, bear in mind that you may have different zone_country_id numbers and different zone_id numbers. As you have exported from your own unique database, these numbers will be genuine for your database, so do not alter them.)

    COPY the exported data to your computer clipboard.

    Open a PLAIN TEXT (or SQL) editor and PASTE the copied lines.

    Then make the following changes (compare the SQL above with the changes below)
    Code:
    UPDATE `zones` SET `zone_id` = 1,`zone_country_id` = 223,`zone_code` = 'AL',`zone_name` = 'AL' WHERE  `zones`.`zone_id` = 1;
    UPDATE `zones` SET `zone_id` = 2,`zone_country_id` = 223,`zone_code` = 'AK',`zone_name` = 'AK' WHERE  `zones`.`zone_id` = 2;
    When all the lines are edited (by changing the COUNTRY NAME TEXT as shown above to the ID TEXT), highlight and copy all the lines, making sure each record has a ; at the end of the line.

    Go back to phpMyAdmin screen and Click zones icon (left menu) again .

    At top of right hand pane, click SQL.

    Delete any text put in the window by default so you have a clear window.


    PASTE copied lines into window.

    Click GO button.

    Zones will now be named the same as their ISO 2-digit ID's.

    Bear in mind that this is a "site-wide" change - your states will no longer be displayed as the full name - but by their ISO ID.
    Last edited by fairestcape; 26 Feb 2009 at 11:05 AM.

  3. #3
    Join Date
    Nov 2004
    Posts
    364
    Plugin Contributions
    0

    Default Re: Change State to use ISO Codes

    Thanks fairestcape,

    So then the zone name is just a label and not used for any program flow?

    Could I just do an sql:

    UPDATE zones SET zone_name = zone_code WHERE 1;
    Experience is what you get when you don’t get what you want…

  4. #4
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Change State to use ISO Codes

    kwright, yes, that's much simpler.
    Although to focus on US states specifically I'd suggest you change your WHERE clause to: WHERE zone_country_id = 223;
    .

    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.

 

 

Similar Threads

  1. Need a list of ISO codes - trying to change my shipping system
    By r1formetoo in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 28 Apr 2009, 08:18 PM
  2. ISO Country Codes
    By hales in forum Managing Customers and Orders
    Replies: 2
    Last Post: 10 Aug 2008, 10:08 PM
  3. replace ISO codes for country codes
    By froldao in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 1 May 2008, 05:39 PM
  4. Want to use ISO (3) codes, USA, CAN, GBR, etc
    By kevinw in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 17 Mar 2008, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg