Genic
Genic

Reputation: 193

How to change In Magento order email address format?

I have a problem that i`m playing with for some hours now and is becoming pretty annoyng.

In System->Configuration->Customer configuration -> Address Templates Magento offers the users how to format the addresses ( country, city, region, etc ).

My question is how to change from full region name to region code? I also looked into the code in Mage/Customer/Address and can not seem to find the solution.

Any ideas please? Thank you.

Upvotes: 4

Views: 1124

Answers (1)

Elavarasan
Elavarasan

Reputation: 2669

muhammedv is correct. Editing core files is a bad practice. You found the solution but any way here I have added some code to create new module for this. I'm just rewriting the class.

app/code/local/Packagename/Modulename/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Packagename_Modulename>
      <version>0.1.0</version>
    </Packagename_Modulename>
  </modules>
  <global>
    <blocks>
      <modulename>
        <class>Packagename_Modulename_Block</class>
      </modulename>
            <customer>
                <rewrite>
                    <address_renderer_default>Packagename_Modulename_Block_Customer_Address_Renderer_Default</address_renderer_default>
                </rewrite>
            </customer>
    </blocks>
  </global>
</config> 

app/code/local/Packagename/Modulename/Block/Customer/Address/Renderer/Default.php

    <?php
    class Packagename_Modulename_Block_Customer_Address_Renderer_Default extends Mage_Customer_Block_Address_Renderer_Default
    {

//your stuff goes here..

    }

And finally activate your module in,

app/code/etc/modules/Packagename_Modulename.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Packagename_Modulename>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Packagename_Modulename>
  </modules>
</config>

Please comment here if you have any doubt.

Upvotes: 2

Related Questions