4

how to set custom field in order and use that field in all the appropriate linked pages like order admin grid, customer my account page, order details page in admin. I want to create one field in checkout page and save that field in order details. so that i can show that field in all related order pages. I have seen the below link but no luck. https://stackoverflow.com/questions/17599566/magento-add-custom-attribute-to-order

  • Could any one please help me on this, step by step. – prasad maganti Jun 6 '14 at 14:27
6

Add an observer :

<events>
            <checkout_type_onepage_save_order>
                <observers>
                    <Savefield_observer>
                        <type>singleton</type>
                        <class>mymodule/observer</class>
                        <method>Savefield</method>
                    </Savefield_observer>
                </observers>
            </checkout_type_onepage_save_order>
        </events>

And in the mymodule/savefield/model/obsever.php file add this:

class Mymodule_Savefield_Model_Observer
{
    public function Savefield($observer){
        //get event data
        $event = $observer->getEvent();

                //get order
        $order = $event->getOrder();

        //set the country here
        $order->setMyFiled($fieldVal);
        }   
}
  • Where would the MyField be saved? And how can it be fetched afterwards? – Vladimir Despotovic Oct 12 '17 at 21:19
1

I wanted to add a custom field to checkout/order page and display it on front end. I found the following step by step tutorial which helped me achieve the task. This tutorial explains how to add an HTML text field, save the field in database tables and display the field in Admin View Order page. Complete code required in every step is also provided. It's a helpful resource.

  • 1
    Above link is dead – Garry Nov 11 '16 at 21:10

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.