Magento: save custom address attribute in checkout

后端 未结 1 583
南笙
南笙 2021-01-01 03:15

This is what i did in my website: Admin->Customers->Attributes->Manage Customer Address Attributes and add a new attribute , the user can see it in his/her profile,

相关标签:
1条回答
  • 2021-01-01 03:39

    After looking in the Magento's code and reading the wiki, I was able to complete it, my new attribute was saved in the address edit form in the profile, but was not saved when I enter it in the checkout form, that was because I need to override some Magento core files, the first step was adding the new attribute to app\code\core\Mage\Customer\etc\config.xml, I copied to app\code\core\Mycompany\Customer\etc\config.xml, as my new attribute code is rfc, I located the <fieldsets> entry and

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

    now I need to add the new attribute to the app\code\core\Mage\Customer\Model\Entity\Setup.php i did the same to override, copied to my local namespace, and in the function getDefaultEntities() i locate the

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

    now, I need to do also the same in app\code\core\Mage\Sales\etc\config.xml, but now 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 it can help someone else

    0 讨论(0)
提交回复
热议问题