2

I have added a custom filed mobile number in magento 1.9 both in checkout and customer registration everything working fine if a customer register i can see the value in customer account information field but its not showing in customer address field which is used for shipping address

My first requirement was need a custom field in registration page both checkout and customer registration so first i run this sql

<?php
$installer = $this;
$installer->startSetup();


$installer->addAttribute("customer", "mobile_reg",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Mobile Number",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "mobile_reg");


$used_in_forms=array();

$used_in_forms[]="adminhtml_customer"; 
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
        $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", "mobile_reg",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Mobile Number",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

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


$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->endSetup();

After that we need to use the same field on shipping address also so separatly i run this following query

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("customer_address", "mobile_reg",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Mobile Number",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

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


$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->endSetup();

and my config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Mobilenum_Cusmobile>
      <version>0.0.1</version>
    </Mobilenum_Cusmobile>
  </modules>
  <admin>
        <fieldsets>
            <customer_dataflow>
                <mobile_reg><billing>1</billing><shipping>1</shipping></mobile_reg>
            </customer_dataflow>
        </fieldsets>
    </admin>
  <global>
    <fieldsets> 
     <checkout_onepage_quote>
         <customer_mobile_reg>
            <to_customer>mobile_reg</to_customer>
          </customer_mobile_reg>
     </checkout_onepage_quote>   
    <checkout_onepage_billing> 
        <mobile_reg> 
            <to_customer>*</to_customer> 
        </mobile_reg> 
    </checkout_onepage_billing> 
    <customer_account>
        <mobile_reg>
           <to_quote>customer_mobile_reg</to_quote>
         </mobile_reg>
     </customer_account>     
    <sales_convert_order>
        <customer_mobile_reg>
          <to_quote>*</to_quote>
        </customer_mobile_reg>
    </sales_convert_order>  
</fieldsets>
<fieldsets>
            <sales_convert_quote>
                <customer_mobile_reg><to_order>*</to_order></customer_mobile_reg>
            </sales_convert_quote>
            <sales_convert_order>
                <customer_mobile_reg><to_quote>*</to_quote></customer_mobile_reg>
            </sales_convert_order>

            <sales_copy_order_billing_address>
                <mobile_reg><to_order>*</to_order></mobile_reg>
            </sales_copy_order_billing_address>

            <sales_copy_order_shipping_address>
            <mobile_reg><to_order>*</to_order></mobile_reg>
          </sales_copy_order_shipping_address>

          <sales_convert_quote_address>
            <mobile_reg><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></mobile_reg>
          </sales_convert_quote_address>

          <sales_convert_order_address>
            <mobile_reg><to_quote_address>*</to_quote_address></mobile_reg>
          </sales_convert_order_address>

          <customer_address>
            <mobile_reg><to_quote_address>*</to_quote_address></mobile_reg>
          </customer_address>

          <checkout_onepage_billing>
            <mobile_reg><to_customer>*</to_customer></mobile_reg>
          </checkout_onepage_billing>

          <checkout_onepage_quote>
            <mobile_reg><to_customer>*</to_customer></mobile_reg>
          </checkout_onepage_quote>
        </fieldsets>
        <helpers>
      <cusmobile>
        <class>Mobilenum_Cusmobile_Helper</class>
      </cusmobile>
    </helpers>
    <models>
      <cusmobile>
        <class>Mobilenum_Cusmobile_Model</class>
        <resourceModel>cusmobile_mysql4</resourceModel>
      </cusmobile>
    </models>
    <resources>
      <customerattribute1486024557_setup>
        <setup>
          <module>Mobilenum_Cusmobile</module>
          <class>Mage_Customer_Model_Entity_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </customerattribute1486024557_setup>
      <customerattribute1486024557_write>
        <connection>
          <use>core_write</use>
        </connection>
      </customerattribute1486024557_write>
      <customerattribute1486024557_read>
        <connection>
          <use>core_read</use>
        </connection>
      </customerattribute1486024557_read>
    </resources>
  </global>
</config> 

enter image description here

enter image description here

12
  • hi amith please clarify the prntscr.com/fp3sod so that i can assist u. Jun 28, 2017 at 10:17
  • @NAGARAJU KASA Please check mu question added 2 screen shot
    – amith lal
    Jun 28, 2017 at 10:33
  • @NAGARAJU KASA Now as we discussed before i got the custom field value in account information this can only getting through registration here i used mobile number insted of telephone in checkout form removing telephone from Required field and make mobile as required so if a user checkout as guest he will only fill the mobile number field that i need to get in back end with shipping address and billing address
    – amith lal
    Jun 28, 2017 at 10:45
  • Now Please confirm you would like to add a customer attribute field to customer address am i correct? Jun 29, 2017 at 4:08
  • @NAGARAJU KASA YA UR RIGHT But please note that i need this in shipping information for all type user if a user checkout as guest i need to show this on order details(in shipping and billing address)
    – amith lal
    Jun 29, 2017 at 4:13

1 Answer 1

0

From your question, it sounds like you added your mobile number attribute to customer entity which is wrong. You should add it as an attribute of customer address entity.

If I am wrong with my assessment, then please add more details to your question such as the attribute declaration code etc.

1
  • Please see my updated code
    – amith lal
    Jun 28, 2017 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.