I've created a custom module to add 10 custom fields in customer register page, following this topic, and it works fine: Add new field in magento(1.9) customer registration
Perhaps, this doesn't work in checkout registration page. I tried many settings, but the information doesn't even get saved in sales_flat_quote table. Here's my code for reference. Thanks for your help!
sql->install-1.0.0.php
<?php
$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
/* --------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CAMPOS PARA INFORMAÇÕES DO CLIENTE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-------------------------------- */
/* PESSOA FÍSICA OU JURÍDICA */
$this->addAttribute('customer', 'tipo', array(
'type' => 'varchar',
'label' => 'Tipo de conta',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 35,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'tipo');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA FÍSICA - CPF */
$this->addAttribute('customer', 'cpf', array(
'type' => 'varchar',
'label' => 'CPF',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1020,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'cpf');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA FÍSICA - NASCIMENTO */
$this->addAttribute('customer', 'nascimento', array(
'type' => 'varchar',
'label' => 'Data de nascimento',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1021,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'nascimento');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA JURÍDICA - CNPJ */
$this->addAttribute('customer', 'cnpj', array(
'type' => 'varchar',
'label' => 'CNPJ',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1020,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'cnpj');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA JURÍDICA - RAZÃO SOCIAL */
$this->addAttribute('customer', 'razao', array(
'type' => 'varchar',
'label' => 'Razão Social',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1020,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'razao');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA JURÍDICA - NOME FANTASIA */
$this->addAttribute('customer', 'fantasia', array(
'type' => 'varchar',
'label' => 'Nome Fantasia',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1020,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'fantasia');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* PESSOA JURÍDICA - INSCRIÇÃO ESTADUAL */
$this->addAttribute('customer', 'ie', array(
'type' => 'varchar',
'label' => 'Inscrição Estadual',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1020,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'ie');
$attribute->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* --------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-------------------------------- */
/* --------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CAMPOS PARA INFORMAÇÕES DE ENDEREÇO
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-------------------------------- */
/* CRIA CAMPO - NÚMERO */
$this->addAttribute('customer_address', 'numero', array(
'type' => 'varchar',
'label' => 'Número',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1022,
'required' => true,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'numero');
$attribute->setData('used_in_forms', array(
'adminhtml_customer_address',
'checkout_register',
'customer_account_create',
'customer_account_edit',
'customer_address_edit',
'customer_register_address'
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* CRIA CAMPO - BAIRRO*/
$this->addAttribute('customer_address', 'bairro', array(
'type' => 'varchar',
'label' => 'Bairro',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1040,
'required' => true,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'bairro');
$attribute->setData('used_in_forms', array(
'adminhtml_customer_address',
'checkout_register',
'customer_account_create',
'customer_account_edit',
'customer_address_edit',
'customer_register_address'
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* CRIA CAMPO - COMPLEMENTO DO ENDEREÇO */
$this->addAttribute('customer_address', 'complemento', array(
'type' => 'varchar',
'label' => 'Complemento',
'input' => 'text',
'global' => 1,
'visible' => 1,
'user_defined' => 1,
'visible_on_front' => 3,
'position' => 1050,
'required' => false,//or true
'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'complemento');
$attribute->setData('used_in_forms', array(
'adminhtml_customer_address',
'checkout_register',
'customer_account_create',
'customer_account_edit',
'customer_address_edit',
'customer_register_address'
));
$attribute->setData('is_user_defined', 0);
$attribute->save();
/* --------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-------------------------------- */
$tablequote = $this->getTable('sales/quote');
$installer->run(" ALTER TABLE $tablequote ADD `customer_tipo` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_cpf` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_nascimento` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_cnpj` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_razao` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_fantasia` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_ie` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_numero` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_bairro` VARCHAR( 255 ) NOT NULL ");
$installer->run(" ALTER TABLE $tablequote ADD `customer_complemento` VARCHAR( 255 ) NOT NULL ");
$installer->endSetup();
stackexchange_customer.xml
<?xml version="1.0"?>
<layout>
<customer_account_edit>
<reference name="customer_edit">
<action method="setTemplate">
<template>stackexchange_customer/form/edit.phtml</template>
</action>
</reference>
</customer_account_edit>
<customer_account_create>
<reference name="customer_form_register">
<action method="setTemplate">
<template>stackexchange_customer/register.phtml</template>
</action>
</reference>
</customer_account_create>
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate"><template>stackexchange_customer/form/billing.phtml</template></action>
<block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml" />
<block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
</reference>
</checkout_onepage_index>
</layout>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<StackExchange_Customer>
<version>1.0.0</version>
</StackExchange_Customer>
</modules>
<global>
<fieldsets>
<checkout_onepage_quote>
<customer_tipo>
<to_customer>tipo</to_customer>
</customer_tipo>
<customer_cpf>
<to_customer>cpf</to_customer>
</customer_cpf>
<customer_nascimento>
<to_customer>nascimento</to_customer>
</customer_nascimento>
<customer_cnpj>
<to_customer>cnpj</to_customer>
</customer_cnpj>
<customer_razao>
<to_customer>razao</to_customer>
</customer_razao>
<customer_fantasia>
<to_customer>fantasia</to_customer>
</customer_fantasia>
<customer_ie>
<to_customer>ie</to_customer>
</customer_ie>
<customer_numero>
<to_customer>numero</to_customer>
</customer_numero>
<customer_bairro>
<to_customer>bairro</to_customer>
</customer_bairro>
<customer_complemento>
<to_customer>complemento</to_customer>
</customer_complemento>
</checkout_onepage_quote>
<checkout_onepage_billing>
<tipo>
<to_customer>*</to_customer>
</tipo>
<cpf>
<to_customer>*</to_customer>
</cpf>
<nascimento>
<to_customer>*</to_customer>
</nascimento>
<cnpj>
<to_customer>*</to_customer>
</cnpj>
<razao>
<to_customer>*</to_customer>
</razao>
<fantasia>
<to_customer>*</to_customer>
</fantasia>
<ie>
<to_customer>*</to_customer>
</ie>
<numero>
<to_customer>*</to_customer>
</numero>
<bairro>
<to_customer>*</to_customer>
</bairro>
<complemento>
<to_customer>*</to_customer>
</complemento>
</checkout_onepage_billing>
<customer_account>
<tipo>
<to_quote>customer_tipo</to_quote>
</tipo>
<cpf>
<to_quote>customer_cpf</to_quote>
</cpf>
<nascimento>
<to_quote>customer_nascimento</to_quote>
</nascimento>
<cnpj>
<to_quote>customer_cnpj</to_quote>
</cnpj>
<razao>
<to_quote>customer_razao</to_quote>
</razao>
<fantasia>
<to_quote>customer_fantasia</to_quote>
</fantasia>
<ie>
<to_quote>customer_ie</to_quote>
</ie>
<numero>
<to_quote>customer_numero</to_quote>
</numero>
<bairro>
<to_quote>customer_bairro</to_quote>
</bairro>
<complemento>
<to_quote>customer_complemento</to_quote>
</complemento>
</customer_account>
<sales_convert_order>
<customer_tipo>
<to_quote>*</to_quote>
</customer_tipo>
<customer_cpf>
<to_quote>*</to_quote>
</customer_cpf>
<customer_nascimento>
<to_quote>*</to_quote>
</customer_nascimento>
<customer_cnpj>
<to_quote>*</to_quote>
</customer_cnpj>
<customer_razao>
<to_quote>*</to_quote>
</customer_razao>
<customer_fantasia>
<to_quote>*</to_quote>
</customer_fantasia>
<customer_ie>
<to_quote>*</to_quote>
</customer_ie>
<customer_numero>
<to_quote>*</to_quote>
</customer_numero>
<customer_bairro>
<to_quote>*</to_quote>
</customer_bairro>
<customer_complemento>
<to_quote>*</to_quote>
</customer_complemento>
</sales_convert_order>
</fieldsets>
<helpers>
<stackexchange_customer>
<class>StackExchange_Customer_Helper</class>
</stackexchange_customer>
</helpers>
<resources>
<stackexchange_customer_setup>
<setup>
<module>StackExchange_Customer</module>
<class>Mage_Customer_Model_Resource_Setup</class>
</setup>
</stackexchange_customer_setup>
</resources>
</global>
<frontend>
<layout>
<updates>
<stackexchange_customer>
<file>stackexchange_customer.xml</file>
</stackexchange_customer>
</updates>
</layout>
</frontend>
</config>
And, under billing.phtml, here's the code for a row with two attributes, for reference:
<li class="fields pessoa-fisica">
<!-- || CPF || -->
<div class="field">
<label for="billing:cpf"><em>*</em><?php echo $this->__('CPF') ?></label>
<div class="input-box">
<input type="text" name="billing[cpf]" id="billing:cpf" value="<?php echo $this->escapeHtml($this->getAddress()->getCpf()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('CPF')) ?>" class="input-text cpf" />
</div>
</div>
<!-- || || -->
<!-- || DATA DE NASCIMENTO || -->
<div class="field">
<label for="billing:nascimento" ><em>*</em><?php echo $this->__('Data de Nascimento') ?></label>
<div class="input-box">
<input type="text" name="billing[nascimento]" id="billing:nascimento" value="<?php echo $this->escapeHtml($this->getAddress()->getNascimento()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Data de Nascimento')) ?>" class="input-text nascimento" />
</div>
</div>
<!-- || || -->
</li>
PS: As you can see, 3 of the 10 customer attributes are from "customer_address". I don't know if it changes something, but i hope it does.