How do I change the format of a Magento email address?

I have a problem that I have been playing with for hours and getting pretty annoying.

The System->Configuration->Customer configuration -> Address Templates

Magento offers users to format addresses (country, city, region, etc.).

My question is how to change the full region name to the region code? I have also looked at the code in Mage/Customer/Address

and cannot find a solution.

Any ideas please? Thank.

+3


source to share


1 answer


muhammedv is correct. Editing core files is bad practice. You found a solution, but here I added some code to create a new module for this. I am 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> 

      

Application / Code / Local / Package / MODULENAME / Block / Client / 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,

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 doubts.

+2


source







All Articles