I need to add a field to the checkout process for my store. I have created a field on the frontend where a user can type in the 'Mail Hub' for their location.
How do I capture this information in the backend?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI need to add a field to the checkout process for my store. I have created a field on the frontend where a user can type in the 'Mail Hub' for their location.
How do I capture this information in the backend?
You need to add an attribute to the customer address eav model in your setup scripts. Something like this:
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer_address', 'field', array(
'label' => 'Field',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => true,
'position' => 1,
));
and capture an event in your module's observer. You can use this event for example: checkout_type_onepage_save_order
Then in your observer method
public function observerMethod(Varien_Event_Observer $observer) {
$address = $observer->getQuote()->getShippingAddress();
$address->set{yourFieldName}(Mage::app()->getRequest()->getParam('{yourFieldName}'))->save();
return $this;
}