You can do this at-least in two ways.
1. Observer way - Recommending Way
If you want to see this change in admin side, then you can observe to the event customer_address_format
and define following observer method within it.
public function changeRegionText(Varien_Event_Observer $observer)
{
$address = $observer->getAddress();
//makes sure change apply to only billing and shipping address types
if ($address->getAddressType()=='shipping' || $address->getAddressType()=='billing') {
$code = $address->getRegionCode();
$address->setRegion($code);
}
return $this;
}
As you can see, I am just grabbing region code from address entity and then forcefully set it as region.
You can also listen to a 'broader event' sales_order_address_collection_load_after
and do the same thing by looping through the collection. ie.
public function changeRegionText(Varien_Event_Observer $observer)
{
$collection = $observer->getOrderAddressCollection();
foreach ($collection as $address) {
//makes sure change apply to only billing and shipping address types
if ($address->getAddressType()=='shipping' || $address->getAddressType()=='billing') {
$code = $address->getRegionCode();
$address->setRegion($code);
}
}
return $this;
}
This broader way allows to give your change permanently everywhere in your instance.
2. Rewrite Way - Easy Nasty Way
If you want to do the change in admin side, then you need to rewrite block class Mage_Customer_Block_Address_Renderer_Default
through your module and customize render()
method.
This is because this class what actually responsible for rendering billing & shipping address in admin side. You need to replace below code line
$data['region'] = Mage::helper('directory')->__($address->getRegion());
with
$data['region'] = Mage::helper('directory')->__($address->getRegionCode());
which you can find inside render()
method.