0

I need to add a custom field "Mobile" in registration and checkout pages.I have tried few methods but no luck. How can I achieve this?

config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Mobilenum_Cusmobile>
      <version>0.0.1</version>
    </Mobilenum_Cusmobile>
  </modules>
  <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>
        <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> 

app/code/local/Mobilenum/Cusmobile/sql/customerattribute1486024557_setup/mysql4-install-0.0.1.php

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

Kindly follow the below steps: I am posting the answer as per below considerations

1) module name: Ewall_Test II) Attribute code: custom_mobile

Step 1: create a module using silk software with customer attribute (which i have posted first answer)

Step 2: app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml

Keep the below code in the billing.phtml

<?php if(!$this->isCustomerLoggedIn()): ?>
<div class="field">
 <label for="billing:custom_mobile" class="required"><em>*</em><?php echo $this->__('Mobile Custom filed') ?></label>
    <div class="input-box">
     <input type="text" autocapitalize="off" autocorrect="off" spellcheck="false" name="billing[custom_mobile]" id="billing:custom_mobile" value="<?php echo $this->escapeHtml($this->getAddress()->getCustomMobile()) ?>" title="<?php echo $this->quoteEscape($this->__('Mobile Custom filed')) ?>" class="input-text required-entry" />
</div>
</div>
<?php endif; ?>

Step 3: go to 'app/code/Ewall/Test/etc/config.xml' of your module for customer attribute add below code inside the global tags

<fieldsets> 
     <checkout_onepage_quote>
         <customer_custom_mobile>
            <to_customer>custom_mobile</to_customer>
          </customer_custom_mobile>
     </checkout_onepage_quote>   
    <checkout_onepage_billing> 
        <custom_mobile> 
            <to_customer>*</to_customer> 
        </custom_mobile> 
    </checkout_onepage_billing> 
    <customer_account>
        <custom_mobile>
           <to_quote>customer_custom_mobile</to_quote>
         </custom_mobile>
     </customer_account>     
    <sales_convert_order>
        <customer_custom_mobile>
          <to_quote>*</to_quote>
        </customer_custom_mobile>
    </sales_convert_order>  
</fieldsets>

Screenshot: enter image description here

Step 4: after adding the above code in the config.xml go to your database and find the table sales_flat_quote and then create a new column as shown below screenshot

Screenshot:

enter image description here

Step 5:

Clear cache & session and go to checkout registration and do the process and check the same. thanks

  • i have added the xml code but the column was not added in sales flat quote table i don't know why it is – amith lal Jun 15 '17 at 4:29
  • please take a screenshot of the error u r getting. – NIPPU Jun 15 '17 at 4:31
  • @ NAGARAJU KASA if you give me your email or skype id i can share the credential with you – amith lal Jun 15 '17 at 5:04
  • please confirm whether u r getting this error prntscr.com/fjy6rp – NIPPU Jun 15 '17 at 5:18
  • @ NAGARAJU KASA ya im getting this error – amith lal Jun 15 '17 at 6:21
1

Note I: Based on your question i have tried in default magento and got the solution.

Please follow the below steps and try the same in your local/default magento. Here i am showing you how to create a customer custom attribute and save the filed value while customer register from frontend.

Step1: Create a customer attribute using silk software tool.

create a module for customer attribute

Please specify the details as shown in the screenshot and download the module and install the module in your magento. don't forget to clear cache and session after installed the module.

Note II: Now login to admin and check the customer details you can able to view the new attribute text field.

enter image description here just check whether you are able to save and update the filed properly or not.

Step2: File path: app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml

Keep the below code in the register.pthml

<label for="custom_mobile"><em>*</em><?php echo $this->__('Custom Mobile Field') ?></label>
<div class="input-box">
<input type="text" autocapitalize="off" autocorrect="off" spellcheck="false" name="custom_mobile" id="custom_mobile" value="<?php echo $this->escapeHtml($this->getFormData()->getCustomMobile()) ?>" 
title="<?php echo $this->quoteEscape($this->__('Custom Mobile')) ?>" class="input-text" />
</div>

keep the code as shown this screen shot

Note III: if the field want to required you can specify the class required.

Step 3: Now click on register button and do the process as shown below screenshot.

click on register

Step 4: output screenshot here i am showing you. please check it admin end

  • i have tried this before an i got this but my problem is i cant save the value using this on checkout registration how can i create this for both customer registration and checkout registration – amith lal Jun 14 '17 at 4:21
  • My requirement is this i need a custom module mobile number which is used both in customer registration and checkout registration hear i make mobile as required filed and make telephone not required field. So i have to get the mobile number from customer from checkout registration ,Checkout as guest and customer registration how can i do this using this tool – amith lal Jun 14 '17 at 6:14
  • Yes @amith i do understand your requirement. upto registration process i have posted answer, please confirm whether the above process has been worked or not? – NIPPU Jun 14 '17 at 8:31
  • yes its is working one i have already created the module you can see that code hear magento.stackexchange.com/questions/176915/… – amith lal Jun 14 '17 at 8:34
  • ok but while checkout registration process you are unable to save the value i am correct ? please confirm. thanks – NIPPU Jun 14 '17 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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