Add new customer address attribute in magento1

In this extension we add two customer address attribute like a (i) “Reference Address1” which is required.
(ii) “Reference Address2” which is not required.
Note:- you can download extension from this rar_image
Note:- Firstly disable the cache from Cache Management tab and which is in System tab.
there are many steps to create the extension.

Step1:- Create Mywork_AddCustomCustomerAddressAttribute.xml file in app/etc/modules/.
where Mywork is Namespace and AddCustomCustomerAddressAttribute is Modulename.
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_AddCustomCustomerAddressAttribute>
<active>true</active>
<codePool>local</codePool>
</Mywork_AddCustomCustomerAddressAttribute>
</modules>
</config>
[/php]

Note:- 1) If you want to activate the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create our own extension then we use the local code pool.

Step2:- Now create the config.xml file in app/code/local/Mywork/AddCustomCustomerAddressAttribute/etc/
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_AddCustomCustomerAddressAttribute>
<version>1.0.0</version>
</Mywork_AddCustomCustomerAddressAttribute>
</modules>
<global>
<helpers>
<AddCustomCustomerAddressAttribute>
<class>Mywork_AddCustomCustomerAddressAttribute_Helper</class>
</AddCustomCustomerAddressAttribute>
</helpers>
<models>
<AddCustomCustomerAddressAttribute>
<class>Mywork_AddCustomCustomerAddressAttribute_Model</class>
<resourceModel>AddCustomCustomerAddressAttribute_mysql4</resourceModel>
</AddCustomCustomerAddressAttribute>
</models>
<resources>
<AddCustomCustomerAddressAttribute_setup>
<setup>
<module>Mywork_AddCustomCustomerAddressAttribute</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</AddCustomCustomerAddressAttribute_setup>
<AddCustomCustomerAddressAttribute_write>
<connection>
<use>core_write</use>
</connection>
</AddCustomCustomerAddressAttribute_write>
<AddCustomCustomerAddressAttribute_read>
<connection>
<use>core_read</use>
</connection>
</AddCustomCustomerAddressAttribute_read>
</resources>
</global>
</config>
[/php]

Step3:- Now create the mysql4-install-1.0.0.php file in app/code/local/Mywork/AddCustomCustomerAddressAttribute/sql/AddCustomCustomerAddressAttribute_setup/
[php]
<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("customer_address", "reference_address1", array(
"type" => "varchar",
"backend" => "",
"label" => "Reference Address1",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => "Near Reference Address1"

));

$attribute = Mage::getSingleton("eav/config")->getAttribute("customer_address", "reference_address1");
$used_in_forms=array();

$used_in_forms[]="adminhtml_customer_address";
$used_in_forms[]="customer_register_address";
$used_in_forms[]="customer_address_edit";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();

$installer->addAttribute("customer_address", "reference_address2", array(
"type" => "varchar",
"backend" => "",
"label" => "Reference Address2",
"input" => "text",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => "Near Reference Address2"
));

$attribute = Mage::getSingleton("eav/config")->getAttribute("customer_address", "reference_address2");
$used_in_forms=array();

$used_in_forms[]="adminhtml_customer_address";
$used_in_forms[]="customer_register_address";
$used_in_forms[]="customer_address_edit";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 101)
;
$attribute->save();
$installer->endSetup();
[/php]

Step4:- Now create the Data.php file in app/code/local/Mywork/AddCustomCustomerAddressAttribute/Helper/
[php]
<?php
class Mywork_AddCustomCustomerAddressAttribute_Helper_Data extends Mage_Core_Helper_Abstract
{
}
[/php]

Now we are going to design steps

(1) edit.phtml which is in the app/design/frontend/rwd/default/template/customer/address/
[php]
<!——————————————-Reference Address1———————————————>
<li class="fields">
<div class="field">
<label for="reference_address1" class="required"><em>*</em><?php echo $this->__(‘Reference Address1’) ?></label>
<div class="input-box">
<input type="text" name="reference_address1" value="<?php echo $this->escapeHtml($this->getAddress()->getReferenceAddress1()) ?>" title="<?php echo $this->__(‘Reference Address1’) ?>" id="reference_address1" class="input-text required-entry" />
</div>
</div>
</li>

<!———————Reference Address2——————————————->

<li class="fields">
<div class="field">
<label for="reference_address2" class=""><em>*</em><?php echo $this->__(‘Reference Address2’) ?></label>
<div class="input-box">
<input type="text" name="reference_address2" value="<?php echo $this->escapeHtml($this->getAddress()->getReferenceAddress2()) ?>" title="<?php echo $this->__(‘Reference Address2’) ?>" id="reference_address2" class="input-text" />
</div>
</div>
</li>

<!——————————————-End Reference Address————————->
[/php]

Note:- Add this code in edit.phtml file