How to add a new field in address in magento
I need to add 'Email' field in Billing & Shipping address in one-page checkout.
I used the below code to add a new field in the database.
$installer = new开发者_C百科 Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttribute('customer_address', 'ship_email', array(
'label' => 'Shipping Email',
'visible' => 1,
'required' => 1,
'position' => 1,
));
$installer->endSetup();
That field was created successfully. Then I add a new text field with the name ship_email in billing and shipping form. Once I save the form the email didn't save in the database.
Could any one guide me...
Have a look at the comments on http://www.fontis.com.au/blog/magento/custom-customer-signup-attributes
Scroll down to 'The hack is to add the "Flavour" field to the billing address step of the Onepage Checkout.'
Note carefully that the contributor uses the original steps to get a module setup. You will also need to change shipping.phtml as per the billing.phtml instructions provided.
The customer address record already has the defunct field 'Fax'. Just rename that to 'Email2' etc. in the .CSV files. This will get the job done and spare you the effort of redesigning your checkout forms, testing and more testing.
I know that solution is not the 'proper way' but you want to go-live, not spend time on problems that can be worked around.
In magento we can access model class from our view file. Please assign your model with ship_email field value.
for example
$customer=Mage::getModel('customer/customer'); // please find correct model
$customer->setship_email('your form email');
$customer->save();
精彩评论