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.
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 18.104.22.168 also? I do not have a local.xml at app/design/frontend/default/template/layout/local.xml
Even adding this file doesnt work.
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
22.214.171.124 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 126.96.36.199 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.
How to make all these fields optional as these all fields are required.
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