Checkout State Abbreviations in Magento

If you want to show only the state abbreviation (code) in the “State” drop-down in the Magento checkout (e.g. “NY” instead of “New York”) then follow these simple steps:

  1. Create an override of app/design/frontend/base/default/template/customer/form/address.phtml
  2. Find the first script tag around line 27 in the line that says something like echo $this->helper('directory')->getRegionJson().
  3. Copy the code in the snippet below into the script tag:

<?php 
/**  
 * [truncated ...]  
 */
?>
<script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?>
// custom code here:
for(countryId in countryRegions) {
    for(regionId in countryRegions[countryId]) {
        region = countryRegions[countryId][regionId];
        region.name = region.code ? region.code.stripTags() : region.name;
        countryRegions[countryId][regionId] = region;
    }
}
</script>