Show State/Province code in address Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to skip onepage checkout shipping information?How to get shipping amount when it is not set in shipping addressReceived order from a “blocked” countryAddress regions synchronize with an external APIWrong Shipping and billing AddressesMagento 2 : How to Add address attribute in billing address form and convert that value in order addressHow do you make the Place Order button disabled until after the address update button is pushed?Magento 2 checkout shipping address not showing countryMagento 2: How to get default address as an array?Magento 2 for logged In customer need to add shipping address every time i place a new order?

Can an alien society believe that their star system is the universe?

Fundamental Solution of the Pell Equation

Why do we bend a book to keep it straight?

Can a new player join a group only when a new campaign starts?

How come Sam didn't become Lord of Horn Hill?

Extracting terms with certain heads in a function

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

Quick way to create a symlink?

How to compare two different files line by line in unix?

Irreducible of finite Krull dimension implies quasi-compact?

Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

Wu formula for manifolds with boundary

What's the meaning of "fortified infraction restraint"?

How to show element name in portuguese using elements package?

Do wooden building fires get hotter than 600°C?

Can you use the Shield Master feat to shove someone before you make an attack by using a Readied action?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

What are the out-of-universe reasons for the references to Toby Maguire-era Spider-Man in ITSV

Why are both D and D# fitting into my E minor key?

Would "destroying" Wurmcoil Engine prevent its tokens from being created?

How can I use the Python library networkx from Mathematica?

Should I use a zero-interest credit card for a large one-time purchase?

Trademark violation for app?



Show State/Province code in address



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to skip onepage checkout shipping information?How to get shipping amount when it is not set in shipping addressReceived order from a “blocked” countryAddress regions synchronize with an external APIWrong Shipping and billing AddressesMagento 2 : How to Add address attribute in billing address form and convert that value in order addressHow do you make the Place Order button disabled until after the address update button is pushed?Magento 2 checkout shipping address not showing countryMagento 2: How to get default address as an array?Magento 2 for logged In customer need to add shipping address every time i place a new order?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















When a customer make an order, in the shipping and billing address appears the extended Province name (for example "Lecce"). Is it possible to show the Region code "LE" instead of the Region name "Lecce"?



Here there is the DB structure:



Country ID > IT
Code (Region code) > LE
Default_name (Region name) > Lecce


I don't want to modify directly this table "directory_country_region" in the DB.










share|improve this question














bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Where do you want to show this ? In admin side or in customer account section ?

    – Rajeev K Tomy
    Aug 3 '16 at 12:10

















2















When a customer make an order, in the shipping and billing address appears the extended Province name (for example "Lecce"). Is it possible to show the Region code "LE" instead of the Region name "Lecce"?



Here there is the DB structure:



Country ID > IT
Code (Region code) > LE
Default_name (Region name) > Lecce


I don't want to modify directly this table "directory_country_region" in the DB.










share|improve this question














bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Where do you want to show this ? In admin side or in customer account section ?

    – Rajeev K Tomy
    Aug 3 '16 at 12:10













2












2








2








When a customer make an order, in the shipping and billing address appears the extended Province name (for example "Lecce"). Is it possible to show the Region code "LE" instead of the Region name "Lecce"?



Here there is the DB structure:



Country ID > IT
Code (Region code) > LE
Default_name (Region name) > Lecce


I don't want to modify directly this table "directory_country_region" in the DB.










share|improve this question














When a customer make an order, in the shipping and billing address appears the extended Province name (for example "Lecce"). Is it possible to show the Region code "LE" instead of the Region name "Lecce"?



Here there is the DB structure:



Country ID > IT
Code (Region code) > LE
Default_name (Region name) > Lecce


I don't want to modify directly this table "directory_country_region" in the DB.







shipping-address ce-1.9.2.4 code country-regions regions






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 3 '16 at 9:45









stsnowstsnow

11410




11410





bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Where do you want to show this ? In admin side or in customer account section ?

    – Rajeev K Tomy
    Aug 3 '16 at 12:10

















  • Where do you want to show this ? In admin side or in customer account section ?

    – Rajeev K Tomy
    Aug 3 '16 at 12:10
















Where do you want to show this ? In admin side or in customer account section ?

– Rajeev K Tomy
Aug 3 '16 at 12:10





Where do you want to show this ? In admin side or in customer account section ?

– Rajeev K Tomy
Aug 3 '16 at 12:10










1 Answer
1






active

oldest

votes


















0














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'


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) $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.






share|improve this answer























  • which files have I to modify?

    – stsnow
    Aug 3 '16 at 12:41











  • you need to create a module in this case to do both case 1 and 2. I

    – Rajeev K Tomy
    Aug 3 '16 at 13:25











  • What should be the file config.xml?

    – stsnow
    Aug 3 '16 at 14:53











  • @stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

    – Rajeev K Tomy
    Aug 4 '16 at 4:22











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f128722%2fshow-state-province-code-in-address%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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'


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) $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.






share|improve this answer























  • which files have I to modify?

    – stsnow
    Aug 3 '16 at 12:41











  • you need to create a module in this case to do both case 1 and 2. I

    – Rajeev K Tomy
    Aug 3 '16 at 13:25











  • What should be the file config.xml?

    – stsnow
    Aug 3 '16 at 14:53











  • @stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

    – Rajeev K Tomy
    Aug 4 '16 at 4:22















0














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'


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) $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.






share|improve this answer























  • which files have I to modify?

    – stsnow
    Aug 3 '16 at 12:41











  • you need to create a module in this case to do both case 1 and 2. I

    – Rajeev K Tomy
    Aug 3 '16 at 13:25











  • What should be the file config.xml?

    – stsnow
    Aug 3 '16 at 14:53











  • @stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

    – Rajeev K Tomy
    Aug 4 '16 at 4:22













0












0








0







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'


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) $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.






share|improve this answer













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'


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) $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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 3 '16 at 12:24









Rajeev K TomyRajeev K Tomy

14.7k54589




14.7k54589












  • which files have I to modify?

    – stsnow
    Aug 3 '16 at 12:41











  • you need to create a module in this case to do both case 1 and 2. I

    – Rajeev K Tomy
    Aug 3 '16 at 13:25











  • What should be the file config.xml?

    – stsnow
    Aug 3 '16 at 14:53











  • @stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

    – Rajeev K Tomy
    Aug 4 '16 at 4:22

















  • which files have I to modify?

    – stsnow
    Aug 3 '16 at 12:41











  • you need to create a module in this case to do both case 1 and 2. I

    – Rajeev K Tomy
    Aug 3 '16 at 13:25











  • What should be the file config.xml?

    – stsnow
    Aug 3 '16 at 14:53











  • @stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

    – Rajeev K Tomy
    Aug 4 '16 at 4:22
















which files have I to modify?

– stsnow
Aug 3 '16 at 12:41





which files have I to modify?

– stsnow
Aug 3 '16 at 12:41













you need to create a module in this case to do both case 1 and 2. I

– Rajeev K Tomy
Aug 3 '16 at 13:25





you need to create a module in this case to do both case 1 and 2. I

– Rajeev K Tomy
Aug 3 '16 at 13:25













What should be the file config.xml?

– stsnow
Aug 3 '16 at 14:53





What should be the file config.xml?

– stsnow
Aug 3 '16 at 14:53













@stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

– Rajeev K Tomy
Aug 4 '16 at 4:22





@stsnow In order to create a module, multiple files are involving in it. You should know how to create a stand alone module in Magento in order to understand and implement idea which I shared above.

– Rajeev K Tomy
Aug 4 '16 at 4:22

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f128722%2fshow-state-province-code-in-address%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2