Magento Checkout Problem - Custom Customer Attribute not Saved in Checkout Register

Jun 5, 2015 3:24:55 PM

Adding custom customer attributes in Magento's default One Page Checkout is often cumbersome for developers. Most often programmers get stuck while resolving problems encountered in Magento checkout configuration, which is the most important aspect of an eCommerce website.

The Problem

Last month, one of our eCommerce clients was suffering from an unusually high shopping cart abandonment rate while checkout. While working on Magento's default one page checkout module in Magento CE 1.8, I needed to add custom fields for customer in customer's registration form, which is just a small step in "one page checkout".

Though I managed to do everything accurately, the values were not getting saved in the database i.e. in the checkout register. Everything was working properly when I'm saving it either from register page or from the admin panel. But when I was trying to save customer attribute from register page of checkout then it is unable to save value.

Solution Proposed by Daffodil's Magento Team

After a lot of search and debug I figured out that we missed an entry in table name "sales_flat_quote".



[php]$tablequote = $this->getTable('sales/quote');
ALTER TABLE $tablequote ADD `customer_attribute_name` varchar(100) NOT NULL"); [/php]

The above code resolved my problem.

So the installer file should be something like this -

 New Call-to-action

$installer = $this;

$setup = Mage::getModel('customer/entity_setup', 'core_setup');

$setup->addAttribute('customer', 'attribute_name', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'Companycomment',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => '0',
'visible_on_front' => 3,

if (version_compare(Mage::getVersion(), '1.6.0', '<='))
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$setup->addAttributeToSet('customer', $attrSetId, 'General', 'attribute_name');


if (version_compare(Mage::getVersion(), '1.4.2', '>='))
->getAttribute('customer', 'attribute_name')
->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))


$tablequote = $this->getTable('sales/quote');
ALTER TABLE $tablequote ADD `customer_attribute_name` varchar(1000) NOT NULL
$installer->endSetup(); [/php]

Though we solved this problem for Magento CE 1.8, the above method will work on all Magento versions. Stay tuned to our blog for more such exciting stuff. Happy coding!!


Ankita Agrawal

Written by Ankita Agrawal

Ankita Agrawal is leading Magento team and providing best in class e-commerce products and aimed at client satisfaction. She is very good at innovating and implementing latest marketplace solutions. Having a great experience of providing customized and featured products, she fits best for handling higher complexity projects.