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>

2 Comments Checkout State Abbreviations in Magento

    1. Gabriel Somoza

      There could be several reasons why this doesn’t work in your installation. This post was written in 2013 so it’s possible that something changed in Magento 1.9. I recommend hiring a Magento developer to help you with this – he/she should be able to fix it within 30 min or so.

      Reply

Leave a Reply