PHP Magento Tips

How to Show Address Information Fields in Customer Registeration Form in Magento

Rate this posting:
{[['']]}

There are Many Methods to display Address Information Fields in Customer Registeration Form in Magento. Lets Discuss all this steps.

Method 1: This is really a very simple method.

Create local.xml file (if it does not exist already) in [your_package]/[your_theme]/layout/ folder and add following code:

<?xml version="1.0"?>

<layout version="0.1.0">

 <customer_account_create>

  <reference name="customer_form_register">

   <action method="setData">

    <key>show_address_fields</key>

    <value>1</value>

   </action>

  </reference>

 </customer_account_create>

</layout>

Method 2: Create a Simple Module for it.

Step 1: Create Module initialization file. Create a File in app/etc/modules/Mycompany_Addressregifield.xml and add below code in it.

<?xml version="1.0"?>

<config>

    <modules>

        <Mycompany_Addressregifield>

            <active>true</active>

            <codePool>local</codePool>

        </Mycompany_Addressregifield>

    </modules>

</config>

Step 2: Create Module config and system.xml files.

a:) Create file in app/code/local/Mycompany/Addressregifield/etc/config.xml and add below code in it.

<?xml version="1.0"?>

<config>

    <modules>

        <Mycompany_Addressregifield>

            <version>1.0.0</version>

        </Mycompany_Addressregifield>

    </modules>

    <global>

        <blocks>

             <customer>

                 <rewrite>

                     <form_register>Mycompany_Addressregifield_Block_Form_Register</form_register>

                 </rewrite>

             </customer>

         </blocks>

    </global>

</config>

b:) Create  file in app/code/local/Mycompany/Addressregifield/etc/system.xml and add below code in it.

<?xml version="1.0"?>

<config>

    <sections>

        <customer translate="label" module="customer">

            <groups>

                <create_account translate="label">

                    <fields>

                        <mycompany_show_register_address translate="label">

                            <label>Enable Address Fields on Register</label>

                            <frontend_type>select</frontend_type>

                            <source_model>adminhtml/system_config_source_yesno</source_model>

                            <sort_order>0</sort_order>

                            <show_in_default>1</show_in_default>

                            <show_in_website>1</show_in_website>

                            <show_in_store>1</show_in_store>

                        </mycompany_show_register_address>

                    </fields>

                </create_account>

            </groups>

        </customer>

    </sections>

</config>

Step 3: Create block file. Create file in app/code/local/Mycompany/Addressregifield/Block/Form/Register.php and add below code in it.

<?php



class Mycompany_Addressregifield_Block_Form_Register extends Mage_Customer_Block_Form_Register

{

    protected function _prepareLayout()

    {

        $this->showAddressFields();       

        return parent::_prepareLayout();

    }

    public function showAddressFields()

    {

    //customer_create_account_technooze_show_register_address

    $this->setShowAddressFields(Mage::getStoreConfig('customer/create_account/mycompany_show_register_address'));

    }   

}

Method 3: Set setShowAddressFields directly to true in your phtml file.

Open app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml file and find below code:

<?php if($this->getShowAddressFields()): ?>


and just above it add below code:

<?php $this->setShowAddressFields(true) ?>


This will also works well.
Tag : Magento
1 Comments On "How to Show Address Information Fields in Customer Registeration Form in Magento"

The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
ecommerce website development company | ECommerce Development Company in Bangalore|Ecommerce Website Design and Development Company in Bangalore | Magento Development Company

Back To Top