Before make any changes in code make sure you backup all existing magento app. Below steps shows how to add any custom field in account registration form in magento, all the path shown is for default app and replace <yourstore> should be your current theme:
E.g.: Let you want to add mobile field in form
<div class="input-box"> <label for="occupation"><?php echo $this->__('Mobile') ?></label><br/> <input type="text" name="mobile" id="mobile" value="<?php echo $this->htmlEscape($this->getFormData()->getMobile()) ?>" title="<?php echo $this->__('Mobile') ?>" class="input-text" /> </div>
'email' => array( 'type' => 'static', 'label' => 'Email', 'input' => 'text', 'sort_order' => 80, 'validate_rules' => 'a:1{s:16:"input_validation";s:5:"email";}', 'position' => 80, 'admin_checkout' => 1 ),
with this
'email' => array( 'type' => 'static', 'label' => 'Email', 'input' => 'text', 'sort_order' => 80, 'validate_rules' => 'a:1{s:16:"input_validation";s:5:"email";}', 'position' => 80, 'admin_checkout' => 1 ), 'Mobile' => array( 'type' => 'varchar', 'label' => 'Mobile', 'input' => 'text', 'sort_order' => 80, 'validate_rules' => 'a:2: {s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}', 'position' => 80, ),
$customerData = $customerForm->extractData($this->getRequest());
Add below code after above line:
//Add to save mobile in database START here if($this->getRequest()->getParam('mobile')) { $customer->setMobile($this->getRequest()->getParam('mobile')); } //Add to save mobile in database END here
<mobile> <create>1</create> <update>1</update> <name>1</name> </mobile>
<?php $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'mobile'; $settings = array ( 'position' => 1, 'is_required'=> 1 ); $setup->addAttribute('1', $AttrCode, $settings); ?>
Enjoy !!!
©2021. All rights reserved. Terms of Use | Privacy Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Recent Comments