0

I have tried to save a custom field value during checkout registration in customer registration its worked fine i have referred many question in stack exchange based on this problem and nothing work for me . here i'm try to save mobile numbers of customer during their registration (no issue occurred during normal user registration)

Here is my 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>
    </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> 

and the mysql query to run

<?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();
$tablequote = $this->getTable('sales/quote');
$installer->run("
ALTER TABLE $tablequote ADD `customer_mobile_reg` varchar(1000) NOT NULL
");

$installer->endSetup();

here is my billing.phtml

<div class="field">
                <label for="billing:mobile_reg" class="required"><em>*</em><?php echo $this->__('Mobile Number') ?></label>
              <div class="input-box">

            <input type="text" name="billing[mobile_reg]" value="<?php echo $this->escapeHtml($this->getAddress()->getmobile_reg()) ?>" title="<?php echo $this->quoteEscape($this->__('Mobile Number')) ?>" class="input-text" id="billing:mobile_reg" />

    </div>
    </div>
  • Your are created customer attribute not a customer address attribute and your are trying save via billing address object.so need to change some code. – Abdul May 8 '17 at 5:27
  • @ Abdul there i need to save both in customer registration and checkout registration customer registration working fine in checkout what i need to change can you help me – amith lal May 8 '17 at 5:33

Your Answer

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

Browse other questions tagged or ask your own question.