Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Add Address Attributes
 
BoostMyShop
Sr. Member
 
Avatar
Total Posts:  155
Joined:  2008-06-11
France
 

Hello smile

i’d like to add some attributes to customers addresses such as floor, door code ...
In this way, i created the attribute using “$installer->addAttribute(”.
I created attributes for customer_address, quote_address, order_address.

I also edited template to display it in the customer form adress edition in front end.

Everything is OK excepted that i do not retrieve those information when an order is placed.

It seems that i have to overload the function that converts customer addresses to quote and order adresses but i dont know how to do.

Thanks in advance for any help smile

Olixelle

 
Magento Community Magento Community
Magento Community
Magento Community
 
BoostMyShop
Sr. Member
 
Avatar
Total Posts:  155
Joined:  2008-06-11
France
 

Well i found the solutions (not easy):

For example, to add “door code” informations to adresses;

1. Create door_code attribute through installer script:

$installer->addAttribute('customer_address''door_code',array(
                                                            
'type'         => 'varchar',
                                                            
'visible'     => true,
                                                            
'label'        => 'Door Code',
                                                            
'required'  => false
                                                            
));

2. Edit template/customers/address/edit.phtml to add a html field
3. In ur installer script, add the code to create a new column in sales_flat_quote_address table (as it does not manage attributes ???)

$installer->run("ALTER TABLE `sales_flat_quote_address` ADD `mobile` varchar(20) NULL;");

4. We need to add code that will copy door_code frpom customer_adress entity to sales_flat_quote_address: edit code/core/mage/sales/etc/config.xml and add <door_code> markup in <sales_convert_quote_address> and <customer_address>

5. To display those information in back end, edit “app/code/core/mage/customer/etc/config.xml” and edit global/customer/address to display information using {{depend}}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Teng
Jr. Member
 
Total Posts:  1
Joined:  2008-10-08
 

Hi all,

I am a new user in China, and I try to add address attribute but I can’t add it.  Could you tell me the detail, step by step?

Thanks a lot!!!~~

 
Magento Community Magento Community
Magento Community
Magento Community
 
vali_cd
Member
 
Total Posts:  33
Joined:  2008-10-08
 

hi

can you please explain this issue a bit more precisely? i tried to add some fields in the same manner, but got no succesful result

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
l781
Sr. Member
 
Total Posts:  109
Joined:  2008-11-09
 

Hi.

this topic is very interesting to me. I read wiki tutorial how to add field to customer registration form - but when i try to add field to customer addresses - i cannot write and properly read from/to database.

Maybe somebody can explain step by step, how to add Company ID field to adresses. It is good also to move VAT number prom Custome profile page to Addresses page, near Company information (company name, ID, VAT...).

 
Magento Community Magento Community
Magento Community
Magento Community
 
l781
Sr. Member
 
Total Posts:  109
Joined:  2008-11-09
 

Look at here:
http://www.magentocommerce.com/extension/reviews/module/898

 
Magento Community Magento Community
Magento Community
Magento Community
 
ikertxu
Jr. Member
 
Total Posts:  1
Joined:  2011-05-24
 

This worked for me :D

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

// Check if the attribute exists. If not, then we proceed to add it
if(!$idAttr $setup->getAttributeId('customer_address''rif')) {
    
// adds the attribute to the database
    
$addAttr $setup->addAttribute('customer_address''rif', array(
        
'type'            => 'varchar',
        
'input'            => 'text',
        
'label'         => 'Rif',
        
'visible'       => true,
        
'required'      => false,
        
'unique'        => false,
        
'position'        => 1,
    ));
    
    
// get the attribute id
    
$idAttr $setup->getAttributeId('customer_address''rif');
    
    
$db Mage::getSingleton('core/resource')->getConnection('core_write');
    
// to link the attribute to the backend
    
$sql "INSERT INTO mag_customer_form_attribute (form_code, attribute_id)
            VALUES ('adminhtml_customer_address', 
$idAttr)";
    
$db->query($sql);
    
// to link the attribute to the frontend to edit
    
$sql "INSERT INTO mag_customer_form_attribute (form_code, attribute_id)
            VALUES ('customer_address_edit', 
$idAttr)";
    
$db->query($sql);
    
// to link the attribute to the frontend to create
    
$sql "INSERT INTO mag_customer_form_attribute (form_code, attribute_id)
            VALUES ('customer_register_address', 
$idAttr)";
    
$db->query($sql);
}

after this, you must add the fields in

root/app/design/frontend/base/default/template/customer/address/edit.phtml

<li class="wide">
    <
label for="rif">Rif</label>
    <
div class="input-box">
        <
input type="text" name="rif" value="<?php echo $this->htmlEscape($this->getAddress()->getRif()) ?>" title="Rif" id="rif" class="input-text" />
    </
div>
</
li>

There’s another problem. When you add the input fields into the checkout form to add new addresses doesn’t save the new attribute. StackOverflow solution to the problem <-- this hasn’t worked for me rolleyes

 
Magento Community Magento Community
Magento Community
Magento Community
 
kdtips
Member
 
Avatar
Total Posts:  73
Joined:  2011-08-13
Auckland New Zealand
 

I am not sure i haven’t done anything like that before.

But if i am not wrong then Address attributes in magento database is belong to order not the customer.

So yep instead of creating customer attribute try to create the order attribute and then i am sure you able to see that attribute in order.

 
Magento Community Magento Community
Magento Community
Magento Community
 
EURO
Jr. Member
 
Total Posts:  23
Joined:  2009-02-26
 

You can add custom attributes to addresses with this free module.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Hello,

you may also like Custom Address Fields module that will help you get more address-related and contact information from customers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
FMEExtensions
Mentor
 
Avatar
Total Posts:  1298
Joined:  2009-08-07
 

Please check the following module, it allows you to add custom attributes for customers,

FME Customer Attributes Extension for Magento

 
Magento Community Magento Community
Magento Community
Magento Community
 
aheadWorks
Guru
 
Avatar
Total Posts:  424
Joined:  2008-10-30
 

The Customer Attributes Magento extension gives you a possibility to create additional customer attributes and display them on the registration form or in the customer account area to allow logged in visitors to manage their data. Your customers are asked to leave some additional info and you get knowledge about them immediately.

Visit the product page and learn more about the module.

Image Attachments
CA1.pngCA11.pngCA2.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
thibautcourtois
Jr. Member
 
Total Posts:  13
Joined:  2014-02-17
 

Hi, you may follow this tutorial to add new customer attribute in Magento
How to add new Customer attributes in Magento
Hope this helps

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top