Magento: save custom address attribute at checkout

this is what I did on my website: Admin-> Customers-> Attributes-> Manage attributes of the client’s address and add a new attribute, the user can see it in his profile, in the "My Addresses" section, the new attribute can be edited and saved when creating a new address, I can also see it in the backend and edit until everything is in order, my problem is to check, I already have a field in billing and sending forms and I want the new attribute to be saved, when the user clicks the "Place order" button az, "but the check shows that he knows nothing about the new attribute, the attribute is not saved, and if I save one value from the user profile check, load it into the field.

what can i do here?

thanks

+4
source share
1 answer

After viewing the magento code and reading the wiki, I was able to complete, my new attribute was saved in the address editing form in the profile, but was not saved when I enter it into the extract form, this was because I needed to redefine some of the main magento files, the first step was to add a new attribute in app\code\core\Mage\Customer\etc\config.xml , I copied to app\code\core\Mycompany\Customer\etc\config.xml , since my new attribute code is rfc , I find the <fieldsets> entry and

 <customer_dataflow> .... <rfc><billing>1</billing><shipping>1</shipping></rfc> </customer_dataflow> 

Now I need to add a new attribute in app\code\core\Mage\Customer\Model\Entity\Setup.php , I did the same to override, copy to my local namespace and in the getDefaultEntities() function find the local

 'customer_address'=>array( .... 'rfc' => array( 'label' => 'RFC', 'required' => false, 'sort_order' => 135, ), ) 

Now, I need to do the same in app\code\core\Mage\Sales\etc\config.xml , but now it should look like this:

 <sales_copy_order_billing_address> ..... <rfc><to_order>*</to_order></rfc> </sales_copy_order_billing_address> <sales_copy_order_shipping_address> ...... <rfc><to_order>*</to_order></rfc> </sales_copy_order_shipping_address> <sales_convert_quote_address> ........ <rfc><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></rfc> </sales_convert_quote_address> <sales_convert_order_address> ......... <rfc><to_quote_address>*</to_quote_address></rfc> </sales_convert_order_address> <customer_address> ....... <rfc><to_quote_address>*</to_quote_address></rfc> </customer_address> 

Hope this can help another person

+10
source

Source: https://habr.com/ru/post/1347417/


All Articles