Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8862337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:42:17+00:00 2026-06-14T15:42:17+00:00

I have added 2 custom attributes to the registration form to collect input from

  • 0

I have added 2 custom attributes to the registration form to collect input from the customer in the frontend.

My problem is that data from the frontend registration form is not being stored in the database.

Any data I enter for these fields in the admin area is being stored, but I need to collect the information from the customers. Here’s my code:

app/code/local/Symphony/Khaos/sql/khaos_setup/mysql4-upgrade-0.1.12-0.1.13.php (yes, I’ve tried to get this right a few times ;))

<?php 

$installer = $this;

$installer->startSetup();


$installer->addAttribute('customer', 'source', array(
    'input' => 'text',
    'type' => 'varchar',
    'label' => 'Where did you hear about us?',
    'visible' => 1,
    'required' => 0,
    'position' => 1,
    'sort_order' => 80,        
));

$installer->addAttribute('customer', 'practitioner_referrer', array(
    'input' => 'text',
    'type' => 'varchar',
    'label' => 'Referring practitioner',
    'visible' => 1,
    'required' => 0,
    'position' => 1,
    'sort_order' => 80,        
));


$installer->endSetup();

$customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'source');
$forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
$customer->setData('used_in_forms', $forms);
$customer->save(); 

$customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'practitioner_referrer');
$forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
$customer->setData('used_in_forms', $forms);
$customer->save(); 

app/code/local/Symphony/Khaos/Model/Entity/Setup.php

    <?php 
class Symphony_Khaos_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
{
    public function getDefaultEntities(){

        return array(

                'source'=>array(
                        'type'=> 'static',
                        'label'=> 'source',
                        'visiable' => true,
                        'required' => false,
                        'sort_order' => 80,
                ),

                'practitioner_referrer'=>array(
                        'type'=> 'static',
                        'label'=> 'practitioner_referrer',
                        'visiable' => true,
                        'required' => false,
                        'sort_order' => 80,
                )

        );
    }
} 

app/code/local/Symphony/Khaos/etc/config.xml

    <?xml version="1.0"?>
<!-- 
/**
 * @category   Symphony
 * @package    Symphony_Khaos
 * @author     ModuleCreator
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
 -->
<config>
    <modules>
        <Symphony_Khaos>
            <version>0.1.13</version>
        </Symphony_Khaos>
    </modules>
    <frontend>
        <routers>
            <khaos>
                <use>standard</use>
                <args>
                    <module>Symphony_Khaos</module>
                    <frontName>khaos</frontName>
                </args>
            </khaos>
        </routers>
        <layout>
            <updates>
                <khaos>
                    <file>khaos.xml</file>
                </khaos>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <khaos>
                <use>admin</use>
                <args>
                    <module>Symphony_Khaos</module>
                    <frontName>khaos</frontName>
                </args>
            </khaos>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <khaos module="khaos">
                <title>Khaos</title>
                <sort_order>71</sort_order>               
                <children>
                    <items module="khaos">
                        <title>Manage Items</title>
                        <sort_order>0</sort_order>
                        <action>khaos/adminhtml_khaos</action>
                    </items>
                </children>
            </khaos>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <Symphony_Khaos>
                            <title>Khaos Module</title>
                            <sort_order>10</sort_order>
                        </Symphony_Khaos>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <khaos>
                    <file>khaos.xml</file>
                </khaos>
            </updates>
        </layout>
    </adminhtml>   
    <global>
        <models>
            <khaos>
                <class>Symphony_Khaos_Model</class>
                <resourceModel>khaos_mysql4</resourceModel>
            </khaos>
            <khaos_mysql4>
                <class>Symphony_Khaos_Model_Mysql4</class>
                <entities>
                    <khaos>
                        <table>khaos</table>
                    </khaos>
                </entities>
            </khaos_mysql4>
        </models>
        <resources>
            <khaos_setup>
                <setup>
                    <module>Symphony_Khaos</module>
                    <class>Symphony_Khaos_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </khaos_setup>
            <khaos_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </khaos_write>
            <khaos_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </khaos_read>          
        </resources>
        <blocks>
            <khaos>
                <class>Symphony_Khaos_Block</class>
            </khaos>
        </blocks>
        <helpers>
            <khaos>
                <class>Symphony_Khaos_Helper</class>
            </khaos>
        </helpers>   
        <fieldsets>
            <customer_account>
                <source><create>1</create><update>1</update></source>
                <practitioner_referrer><create>1</create><update>1</update></practitioner_referrer>
            </customer_account>
        </fieldsets>   
    </global>
</config>

app/design/frontend/metabolics/default/template/persistent/checkout/onepage/billing.phtml

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/** @var Mage_Checkout_Block_Onepage_Billing $this */
?>
<form id="co-billing-form" action="">
<fieldset>
    <ul class="form-list">
    <?php if ($this->customerHasAddresses()): ?>
        <li class="wide">
            <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
            <div class="input-box">
                <?php echo $this->getAddressesHtmlSelect('billing') ?>
            </div>
        </li>
    <?php endif; ?>
    <li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
        <fieldset>
            <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
            <ul>
                <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
                <li class="fields">
                    <div class="field">
                        <label for="billing:company"><?php echo $this->__('Company') ?></label>
                        <div class="input-box">
                            <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
                        </div>
                    </div>
        <?php if(!$this->isCustomerLoggedIn()): ?>
                    <div class="field">
                        <label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
                        <div class="input-box">
                            <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
                        </div>
                    </div>
        <?php endif; ?>
                </li>
        <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
                <li class="wide">
                    <label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
                    <div class="input-box">
                        <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
                    </div>
                </li>
        <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
        <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
                <li class="wide">
                    <div class="input-box">
                        <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="billing[street][]" id="billing:street<?php echo $_i ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
                    </div>
                </li>
        <?php endfor; ?>
                <?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
                <li class="wide">
                    <label for="billing:vat_id"><?php echo $this->__('VAT Number') ?></label>
                    <div class="input-box">
                        <input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
                    </div>
                </li>
                <?php endif; ?>
                <li class="fields">
                    <div class="field">
                        <label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
                        <div class="input-box">
                            <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="billing:city" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
                        <div class="input-box">
                            <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
                                <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
                            </select>
                            <script type="text/javascript">
                            //<![CDATA[
                                $('billing:region_id').setAttribute('defaultValue',  "<?php echo $this->getAddress()->getRegionId() ?>");
                            //]]>
                            </script>
                            <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                        </div>
                    </div>
                </li>
                <li class="fields">
                    <div class="field">
                        <label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
                        <div class="input-box">
                            <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
                        <div class="input-box">
                            <?php echo $this->getCountryHtmlSelect('billing') ?>
                        </div>
                    </div>
                </li>
                <li class="fields">
                    <div class="field">
                        <label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
                        <div class="input-box">
                            <input type="text" name="billing[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="billing:telephone" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="billing:fax"><?php echo $this->__('Fax') ?></label>
                        <div class="input-box">
                            <input type="text" name="billing[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="billing:fax" />
                        </div>
                    </div>
                </li>
                <?php if(!$this->isCustomerLoggedIn()): ?>

        <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
        <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
            <?php if ($_dob->isEnabled() || $_gender->isEnabled()): ?>
                <li class="fields">
                <?php if ($_dob->isEnabled()): ?>
                    <div class="field">
                        <?php echo $_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
                    </div>
                <?php endif; ?>
                <?php if ($_gender->isEnabled()): ?>
                    <div class="field">
                        <?php echo $_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
                    </div>
                <?php endif ?>
                </li>
            <?php endif ?>

            <?php if ($this->isTaxvatEnabled()):?>
                <li><?php echo $this->getTaxvatHtml() ?></li>
            <?php endif; ?>

            <div class="fieldset">
            <ul class="form-list">
                <li class="fields">
                    <div class="field">
                        <label for="source" class="required"><em>*</em><?php echo $this->__('Where did you hear about us?') ?></label>
                        <div class="input-box">
                            <input type="text" name="source" id="source" title="<?php echo $this->__('source') ?>" class="input-text required-entry" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="practitioner_referrer"><?php echo $this->__('Were you referrered by a practitioner, if so, who?') ?></label>
                        <div class="input-box">
                            <input type="text" name="practitioner_referrer" id="practitioner_referrer" title="<?php echo $this->__('practitioner_referrer') ?>" class="input-text" />
                        </div>
                    </div>
                </li>
            </ul>
        </div>

                <li class="fields" id="register-customer-password">
                    <div class="field">
                        <label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="input-text required-entry validate-cpassword" />
                        </div>
                    </div>
                </li>
                <?php echo $this->getChildHtml('persistent.remember.me'); ?>
                <?php endif; ?>
                <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
                    <li class="control">
                        <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="billing:save_in_address_book"><?php echo $this->__('Save in address book') ?></label>
                    </li>
                <?php else:?>
                    <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>
                <?php endif; ?>
                <?php echo $this->getChildHtml('form.additional.info'); ?>
            </ul>
            <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
        </fieldset>
     </li>
    <?php if ($this->canShip()): ?>
        <li class="control">
            <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo  $this->__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address') ?></label></li>
        <li class="control">
            <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
        </li>
    <?php endif; ?>
    </ul>
    <?php if (!$this->canShip()): ?>
        <input type="hidden" name="billing[use_for_shipping]" value="1" />
    <?php endif; ?>
    <div class="buttons-set" id="billing-buttons-container">
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
        <button type="button" title="<?php echo $this->__('Continue') ?>" class="button" onclick="billing.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
        <span class="please-wait" id="billing-please-wait" style="display:none;">
            <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
        </span>
    </div>
</fieldset>
</form>
<script type="text/javascript">
//<![CDATA[
    var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
    var billingForm = new VarienForm('co-billing-form');

    //billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
    $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);

    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
    if ($('onepage-guest-register-button')) {
        Event.observe($('onepage-guest-register-button'), 'click', function(event) {
            var billingRememberMe = $('co-billing-form').select('#remember-me-box');
            if (billingRememberMe.length > 0) {
                if ($('login:guest') && $('login:guest').checked) {
                    billingRememberMe[0].hide();
                } else if ($('login:register') && ($('login:register').checked || $('login:register').type == 'hidden')) {
                    billingRememberMe[0].show();
                }
            }
        });
    }
//]]>
</script>

Any help is greatly appreciated.

Kind regards,

James

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:42:18+00:00Added an answer on June 14, 2026 at 3:42 pm

    Your solution is nice, it is close to a working one, however it lacks some final touches.

    Note, that it is possible for a Customer to register in two ways – via “Register” link or during the Checkout. You’ve provided template code for the Checkout process only, so I’ll talk about it only. Implementation for the “Register” link is much more straightforward and seems to be nicely described in the article that has been already provided above: http://www.fontis.com.au/blog/magento/know-more-about-your-customers-adding-custom-signup-attributes

    Ok, regarding the Checkout. The issues with the current solution are:

    1. Wrong name for the input. It should be billing[<attribute_name>].
    2. Data needs to be stored somewhere during the checkout process (new columns in
      Quote table are needed) and saved to customer profile upon order placing
      (fieldset rules are needed)

    Let’s deal with the issues.

    The fix for the template file is simple – just rename the inputs, they should be:

    ...
    
    <input type="text" name="billing[source]" id="source" title="<?php echo 
    $this->__('source') ?>" class="input-text required-entry" />
    
    ...
    
    <input type="text" name="billing[practitioner_referrer]" id="practitioner_referrer"
    title="<?php echo $this->__('practitioner_referrer') ?>" class="input-text" />
    
    ...
    

    This will make Magento find the entered data at a place, where it is expected to be.

    The right sql file (i.e. mysql4-upgrade-0.1.12-0.1.13.php) should look like:

    $installer->startSetup();
    
    $installer->getConnection()->addColumn(
        $installer->getTable('sales/quote'),
        'customer_source',
        array(
            'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
            'length'    => '64K',
            'comment'   => 'Customer Source'
        )
    );
    
    $installer->getConnection()->addColumn(
        $installer->getTable('sales/quote'),
        'customer_practitioner_referrer',
        array(
            'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
            'length'    => '64K',
            'comment'   => 'Customer Practitioner Referrer'
        )
    );
    
    $installer->addAttribute('customer', 'source', array(
        'input' => 'text',
        'type' => 'varchar',
        'label' => 'Where did you hear about us?',
        'visible' => 1,
        'required' => 0,
        'position' => 1,
        'sort_order' => 80
    ));
    
    $installer->addAttribute('customer', 'practitioner_referrer',
        array(
            'input' => 'text',
            'type' => 'varchar',
            'label' => 'Referring practitioner',
            'visible' => 1,
            'required' => 0,
            'position' => 1,
            'sort_order' => 80
        )
    );
    
    $installer->endSetup();
    
    $customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'source');
    $forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
    $customer->setData('used_in_forms', $forms);
    $customer->save();
    
    $customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'practitioner_referrer');
    $forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
    $customer->setData('used_in_forms', $forms);
    $customer->save();
    

    In that file we create not only the Customer attributes, but also the corresponding columns in Quote table, where entered values will be stored during the Checkout process.

    The fieldsets should include rules to convert data from customer to quote and vice versa. So that’s how config.xml should look like:

    <?xml version="1.0"?>
    <!--
    /**
     * @category   Symphony
     * @package    Symphony_Khaos
     * @author     ModuleCreator
     * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
     */
     -->
    <config>
        <modules>
            <Symphony_Khaos>
                <version>0.1.13</version>
            </Symphony_Khaos>
        </modules>
        <frontend>
            <routers>
                <khaos>
                    <use>standard</use>
                    <args>
                        <module>Symphony_Khaos</module>
                        <frontName>khaos</frontName>
                    </args>
                </khaos>
            </routers>
            <layout>
                <updates>
                    <khaos>
                        <file>khaos.xml</file>
                    </khaos>
                </updates>
            </layout>
        </frontend>
        <admin>
            <routers>
                <khaos>
                    <use>admin</use>
                    <args>
                        <module>Symphony_Khaos</module>
                        <frontName>khaos</frontName>
                    </args>
                </khaos>
            </routers>
        </admin>
        <adminhtml>
            <menu>
                <khaos module="khaos">
                    <title>Khaos</title>
                    <sort_order>71</sort_order>
                    <children>
                        <items module="khaos">
                            <title>Manage Items</title>
                            <sort_order>0</sort_order>
                            <action>khaos/adminhtml_khaos</action>
                        </items>
                    </children>
                </khaos>
            </menu>
            <acl>
                <resources>
                    <all>
                        <title>Allow Everything</title>
                    </all>
                    <admin>
                        <children>
                            <Symphony_Khaos>
                                <title>Khaos Module</title>
                                <sort_order>10</sort_order>
                            </Symphony_Khaos>
                        </children>
                    </admin>
                </resources>
            </acl>
            <layout>
                <updates>
                    <khaos>
                        <file>khaos.xml</file>
                    </khaos>
                </updates>
            </layout>
        </adminhtml>
        <global>
            <models>
                <khaos>
                    <class>Symphony_Khaos_Model</class>
                    <resourceModel>khaos_mysql4</resourceModel>
                </khaos>
                <khaos_mysql4>
                    <class>Symphony_Khaos_Model_Mysql4</class>
                    <entities>
                        <khaos>
                            <table>khaos</table>
                        </khaos>
                    </entities>
                </khaos_mysql4>
            </models>
            <resources>
                <khaos_setup>
                    <setup>
                        <module>Symphony_Khaos</module>
                        <class>Mage_Customer_Model_Entity_Setup</class>
                    </setup>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </khaos_setup>
                <khaos_write>
                    <connection>
                        <use>core_write</use>
                    </connection>
                </khaos_write>
                <khaos_read>
                    <connection>
                        <use>core_read</use>
                    </connection>
                </khaos_read>
            </resources>
            <blocks>
                <khaos>
                    <class>Symphony_Khaos_Block</class>
                </khaos>
            </blocks>
            <helpers>
                <khaos>
                    <class>Symphony_Khaos_Helper</class>
                </khaos>
            </helpers>
            <fieldsets>
                <customer_account>
                    <source><to_quote>customer_source</to_quote></source>
                    <practitioner_referrer><to_quote>customer_practitioner_referrer</to_quote></practitioner_referrer>
                </customer_account>
                <checkout_onepage_quote>
                    <customer_source><to_customer>source</to_customer></customer_source>
                    <customer_practitioner_referrer><to_customer>practitioner_referrer</to_customer></customer_practitioner_referrer>
                </checkout_onepage_quote>
            </fieldsets>
        </global>
    </config>
    

    Note two things:

    • <create> and <update> directives were removed, because they are
      not needed for the Checkout registration. You may add them back, if
      you need them.
    • Custom setup model Symphony_Khaos_Model_Entity_Setup
      was removed in favor of Mage_Customer_Model_Entity_Setup. The
      Customer setup model is enough to do all the tasks. The file with
      custom setup model may be deleted at all. You may return the custom
      model, if you need it for other tasks.

    Voila – that’s all! These fixes will make customer see two additional fields during the Checkout registration. And the data will be saved to his profile, when the order is submitted.

    However, the implementation is not the best one, because it is based on the approach, which has some drawbacks. The approach requires storing data in the Quote table, while those data entries have nothing to do with the Quote model. They just utilize it as a transport. Also, adding new attributes in future, will require doing too much work – modifications must be made to sql file, to config and to the template.

    A right approach would be to build a more abstract implementation. The solution should store attribute data in EAV or custom tables, and add them to the Customer/Quote models via observed events, if needed. The templates should show a generic list of attributes, possibly with special rendering models for the ones that require special design.

    But for just 2 attributes your approach is fine.

    Wish you luck with further work with Magento 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a custom theme from themeforest, I have added all my attributes
I have assigned a custom data attribute to some circles added to the Raphael
I have a default ListView that i have added my custom views for the
I have an NSOperationQueue to which i have added my custom class's objects(inherits from
I am using jquery validation plugin for form validation. I have added a custom
I have added custom attribute with the code my_price with Catalog Input Type for
I have created several custom attributes for my products. I have some that need
I have a custom module that exports data to our fulfillment system when the
I have an activity with 2 fragments. I have added custom animations for fragment
In one of the iPad Application, I am working I have added custom views

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.