1

I have created a custom customer_address attribute using below script :

$installer = new Mage_Customer_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttribute('customer_address', 'country_code', array(
 'type' => 'varchar',
 'input' => 'text',
 'label' => 'Country Code',
 'global' => 1,
 'visible' => 1,
 'required' => 0,
 'user_defined' => 1,
 'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
 ->getAttribute('customer_address', 'country_code')
 ->setData('used_in_forms', array('customer_register_address','customer_address_edit','adminhtml_customer_address'))
 ->save();
$installer->endSetup();

and added it in billing.phtml as :

<input type="text" name="billing[country_code]" value="<?php echo $this->escapeHtml($this->getAddress()->getCountryCode()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Country Code')) ?>" class="input-text required-entry " id="billing:country_code" />

But on order place other values saved in customer address but not custom attribute.

How to do that?

asked Nov 5, 2016 at 14:04

1 Answer 1

3

You should follow this article http://excellencemagentoblog.com/blog/2011/11/29/magento-adding-custom-field-to-customer-address/ , especially the last part with Checkout Billing/Shipping Step. Even if the article its a little bit old I think its still allright also for Magento 1.9.

The most important part is that you should also add this custom attribute also on the sales/quote_address and sales/order_address entities in order to have data persistence. And you should also add some extra stuff in the config.xml file.

I hope it helps!

answered Nov 5, 2016 at 18:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.