2011-06-24: Magento: Show address fields in account creation form

Posted at 2011-06-24 15:41:23 by SHD

The Magento eCommerce platform hides the "address fields", including the customer's company name, by default. To enable them, most sources on the internet suggest overriding the register.phtml file and either commenting out the check to getShowAddressFields or to specifically call $this->setShowAddressFields (true);. That'll work, but it's not the proper way to do it. Read on the learn the proper way.

Magento account creation form
The default Magento account creation form does not allow the customer to enter his address information.


First, the quick answer. To enable the address fields, add the following to your app/design/frontend/default/template/layout/local.xml file:

<customer_account_create> <reference name="customer_form_register"> <action method="setShowAddressFields"><param>true</param></action> </reference></customer_account_create>


Magento allows virtually all of its behaviour to be overridden by replacing modules or templates. Making a copy of a template (or worse: editing the ones included in the base package) is overkill for this case and will result in your custom template not being updated or the your changes being overwritten when Magento is updated.

For this reason, even though a simple call to $this->setShowAddressFields (true) would suffice, that should not be done through the template file. Instead, Magento provides a way to do such method calls through its local XML files. That is what happens in the XML snippet above.




Does this work on Magento also? I do not have a local.xml at app/design/frontend/default/template/layout/local.xml
Even adding this file doesnt work.
Any idea?

Posted at 2013-01-16 10:14:17 by Dirk

The italicised "template" in that directory is the name of the template that you're using. If you are using the included "modern" template, it would be "app/design/frontend/default/modern/layout/local.xml"

After editing/creating that file, you should also clear the caches to make sure it is picked up.

Posted at 2013-01-16 23:20:14 by Steven Don

Does not have this file in default or base or in my template.

Posted at 2013-03-08 09:05:16 by Hennie van Rooyen

Really helpful :) Thanks a lot

Posted at 2013-03-22 10:23:10 by srikal To use the file app\design\frontend\default\[you theme]\layout\customer.xml

Thank you! Your article helped me a lot!

Posted at 2013-03-27 02:33:19 by Kseniya

I added just the line <action method="setShowAddressFields"><param>true</param></action>
to a already existing customer_account_create block found in a themed version of magento using the file:

So beware of the version differences, searching for customer_account_create in your sourcetree before you add this block new to some xml file would be smart.

Posted at 2013-03-29 08:15:12 by mjjsmeets

How to make all these fields optional as these all fields are required.
any help?

Posted at 2013-05-24 21:21:33 by Jai

Really Good. Thank you So much

Posted at 2014-03-14 06:50:53 by Renish Khunt

Hi! Thanks for the tutorial! I used that method for some time but then I had to switch to an extension that gives more control over custom address fields. I use the one by Amasty

Posted at 2014-04-09 12:46:10 by Perry

Thanks for the post !!!

Posted at 2014-05-07 13:34:38 by Bikram

Thanks for sharing this great post. The results are published in address field in account creation form. Nice work, keep it up. by https://www.brushyourideas.com/

Posted at 2016-09-26 10:35:29 by Pratik Shah

Is there a way to make the address set as default shipping and billing after registration of a new account?

Posted at 2016-10-05 12:14:15 by MLS

Post a comment

Note: HTML is not permitted, URLs will be linked automatically. Spam comments will result in a permanent ban.
Type these 4 symbols into the edit field