0

I have tried to search for direct information about how to add custom fields to my billing information checkout. Whatever page I visit, it tells me to buy an extension or it describes steps to implement it manually but nothing helped me yet. Is there a clear way to add or edit custom fields in the billing information with descriptions? Please help me out with this.

0
app/design/frontend/yourtheme/default/template/checkout/onepage/billing.phtml

simply add your field

 <input type="text" title="<?php echo $this->__('Custom Fields ') ?>" name="billing[custom_field]" id="billing:custom>" class="input-text" />

add your event in your observer

<frontend>
<events>
      <checkout_type_onepage_save_order_after>
                <observers>
                    <modulename>
                      <type>singleton</type>
                        <class>modulename/observer</class>
                        <method>saveafterorder</method>
                    </modulename>
                </observers>
      </checkout_type_onepage_save_order_after>
    </events>
    </frontend>

your observer

class Spacename_Modulename_Model_Observer {
    public function saveafterorder($observer)
        {
                $event = $observer->getEvent(); 
                $order = $event->getOrder();
                $order_id=$order->getEntityId();


                $billing=Mage::app()->getRequest()->getPost('billing');
             echo   $billing['custom_field'];
         }}
  • Hi, not working for me (Magento 1.9.2.4). Observer is called but billing post data are not supplied. – nicolas Mar 1 '17 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.