- October 2020
- June 2020
- May 2020
- October 2019
- June 2019
- September 2018
- May 2018
- December 2017
- April 2017
- June 2016
- February 2016
- November 2015
- January 2015
- August 2014
- July 2014
- May 2014
- March 2014
- February 2014
- January 2014
- November 2013
- August 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- December 2012
- November 2012
- September 2012
- June 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- September 2011
- July 2011
- June 2011
- May 2011
- March 2011
- January 2011
- October 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- September 2009
- July 2009
- June 2009
- May 2009
- March 2009
- September 2008
- April 2008
- December 2007
- June 2007
- June 2005
- September 2004
- May 2002
- October 2001
- August 2001
2011-06-24: Magento: Show address fields in account creation form
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.
The default Magento account creation form does not allow the customer to enter his address information.
TL;DR
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>
Explanation
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.
Pingbacks
- http://zap-blog.biz/user4/2013/07/09/filter-jython-generated-property-fields-for-getterssetters-from-dir-result/
“filter jython-generated property fields for getters/setters from dir() result | Tech Questions C”
:
Comments
Does this work on Magento 1.7.0.2 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?
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.
Does not have this file in default or base or in my template.
Really helpful :) Thanks a lot
1.7.0.2 To use the file app\design\frontend\default\[you theme]\layout\customer.xml
Thank you! Your article helped me a lot!
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 1.7.0.2 using the file:
app/design/frontend/base/default/layout/persistent.xml
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.
How to make all these fields optional as these all fields are required.
any help?
Really Good. Thank you So much
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
Thanks for the post !!!
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/
Is there a way to make the address set as default shipping and billing after registration of a new account?
Post a comment