Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2016
    Location
    Massachusetts
    Posts
    17
    Plugin Contributions
    0

    Default Forcing State dropdown to two-character abbreviation?

    I've enabled the use of the drop down for a customer entering their state, but I would like to use the two-character abbreviation rather than the full state name. Is there an easy (or moderately involved) solution for this?

    Thanks very much.

    John

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Forcing State dropdown to two-character abbreviation?

    You will need to alter a core file ... one that's often touched by a lot of plugins too. (I say that because you'll need to take care to preserve your changes anytime you touch the file.)

    /includes/functions/functions_general.php
    Around line 1397 (in v1.5.5 anyway) you'll find this:

    Code:
    /** * return an array with zones defined for the specified country
     */
      function zen_get_country_zones($country_id) {
        global $db;
        $zones_array = array();
        $zones = $db->Execute("select zone_id, zone_name
                               from " . TABLE_ZONES . "
                               where zone_country_id = '" . (int)$country_id . "'
                               order by zone_name");
        while (!$zones->EOF) {
          $zones_array[] = array('id' => $zones->fields['zone_id'],
                                 'text' => $zones->fields['zone_name']);
          $zones->MoveNext();
        }
    
    
        return $zones_array;
      }
    Change it in the 2 places (not 3) as highlighted here:
    Code:
    /**
     * return an array with zones defined for the specified country
     */
      function zen_get_country_zones($country_id) {
        global $db;
        $zones_array = array();
        $zones = $db->Execute("select zone_id, zone_name, zone_code
                               from " . TABLE_ZONES . "
                               where zone_country_id = '" . (int)$country_id . "'
                               order by zone_name");
        while (!$zones->EOF) {
          $zones_array[] = array('id' => $zones->fields['zone_id'],
                                 'text' => $zones->fields['zone_code']);
          $zones->MoveNext();
        }
    
    
        return $zones_array;
      }
    .

    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.

  3. #3
    Join Date
    Oct 2016
    Location
    Massachusetts
    Posts
    17
    Plugin Contributions
    0

    Default Re: Forcing State dropdown to two-character abbreviation?

    Thank you so much. The change look simple, but the implications are daunting. Thank you for the warning.

 

 

Similar Threads

  1. v139h Incorrect state abbreviation being passed to ???
    By JeffLC in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 12 Feb 2015, 03:03 PM
  2. v151 Replace states name with state abbreviation on admin orders
    By firebug in forum Managing Customers and Orders
    Replies: 8
    Last Post: 27 Nov 2013, 07:41 PM
  3. State dropdown not showing when entered state wrong
    By xavierpages in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 15 May 2011, 11:17 AM
  4. State Field Showing Below State Dropdown
    By johnfripp in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 10 Feb 2011, 01:34 PM
  5. Replies: 7
    Last Post: 24 Nov 2008, 04:25 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR