Adding a new tab under one page checkout – full working module

Adding a new tab under one page checkout – full working module

Adding a new tab under onepage checkout in Magento might seem as incredibly easy task. right?! Well, it’s not. If you want to do it properly, you gonna have to do some work. Took me few hours to get this one running. Attached are screenshots for you to see final result.

Frontend

Backend1

Here is the module itself Inchoo_Heared4us.

Few words about module. It uses built in Admin theme module from a coworker Ivan Weiler. If you have this Admin theme module installer already please disable it, since its built into this Heared4us module. There is only one thing you NEED TO DO in order for module to work: Once you added it to Magento, go to System > COnfiguration > Design and write down “custom” under Admin theme section. This admin theme section will appear as soon as you refresh Admin page once you copy-pasted module. If you get “Access denie” error, please logout and login into the admin.

That’s it. If you wish to edit the questions that appear under newely added tab, open the app/design/frontend/default/default/template/checkout/onepage/heared4us.phtml file and modify the array at the very top of the file.

DO A FULL DATABASE AND FILE BACKUP BEFORE ADDING A MODULE TO LIVE STORE.
You should always do a full backup when adding modules to live store. Although the module does not have any database dependencies and stuff, it uses overrides on checkout model, controller and block. Use on your own responsibility.

What you can learn from module? -You can learn how to override (extend) default controllers, Models, Blocks. You can learn how to modify existing JS files and reuse them (reused sample of JS for tab, saved it under heared4us.phtml file itself), you can learn how to set custom theme files on admin to avoid modifying default admin theme, learn how to extend order object (or any other, from sql setup file), learn how to “attach a hook” aka observer to event… Lot to learn on a small module like this. Hope it helps.

Cheers.

You made it all the way down here so you must have enjoyed this post! You may also like:

Meet Magento Belarus features an Inchooer talking Magento 2 Checkout Ivona Namjesnik
Ivona Namjesnik, | 0

Meet Magento Belarus features an Inchooer talking Magento 2 Checkout

Tracking Onepage Checkout abandonment using Google Analytics Drazen Karacic-Soljic
Drazen Karacic-Soljic, | 70

Tracking Onepage Checkout abandonment using Google Analytics

CheckItOut, alternative checkout for Magento Branko Ajzele
Branko Ajzele, | 27

CheckItOut, alternative checkout for Magento

168 comments

  1. Yep this works if you follow the instructions and notes and are willing to edit a few files. Pity I cannot upload attachment, mine works fine in 1.6.

  2. ^Correction: I’ve tried to install it again and it works on 1.5.1.0.

    It seems I had to delete cache and session files (var/cache and var/session) to make it work.

  3. I’ve tried this module on fresh magento 1.5.1.0 and it does not Work. Nagaraja, I’ve also addad an extra column ALTER TABLE `sales_flat_order` ADD `heared4us` TEXT NOT NULL

    No change on frontend.

  4. Hi Soumya,

    Please read above comments and try to solve issue. comments named by kharvi and nagaraja are mine .please try with those.this will solve your problem

  5. how to work this module in 1.5.0.1, as extra tab is not coming in onepage chekout frontend..please help..it’s urgent

  6. hi
    I have use this extension and its work fine but i have to use file control in place of text area.
    But i have face some issue.
    when i post my form, i can not get files value.
    So Could u tell me what changes i have to made.

  7. If anybody wants to change the text “How did you heared about us” you can change it on app/code/local/Inchoo/Heared4us/Block/Onepage/Heared4us.php

    since the spelling is incorrect thought this might be helpful

  8. I am using version 1.4.2. The form is displaying on the checkout page but the data is not pulling on the admin section. I could see How did you heard from us but its not pulling any data.
    I have followed all the steps above mentioned. I added a column manually on sales_flat_order and also changed the file mysql4-install-0.1.0.php
    I am running out of options here guys..any help would be appreciated..

  9. Hi.

    I have Magento 1.5 installation.

    I have downloaded this extension and manage to make it appear in checkout and admin panel. But there was no value in admin panel. :-(. Only “Where did you heared about us” section .. No values :-(.. Help me please!

  10. hi

    i have install this module…
    and change admin theme

    now what to do plz tell me in detail….

  11. Darn… I’m ready to throw in the towel…

    Running Magento 1.5.0.1 and no one’s suggestions above is actually even getting to write to the database

    Too bad, because it could of been a REALLY helpful module 🙁

  12. i cant extract that file…
    Archive: /home2/vdslivec/public_html/ranga/app/design/adminhtml/default/custom/Inchoo_Heared4us.zip
    End-of-central-directory signature not found. Either this file is not
    a zipfile, or it constitutes one disk of a multi-part archive. In the
    latter case the central directory and zipfile comment will be found on
    the last disk(s) of this archive.
    unzip: cannot find zipfile directory in one of /home2/vdslivec/public_html/ranga/app/design/adminhtml/default/custom/Inchoo_Heared4us.zip or
    /home2/vdslivec/public_html/ranga/app/design/adminhtml/default/custom/Inchoo_Heared4us.zip.zip, and cannot find /home2/vdslivec/public_html/ranga/app/design/adminhtml/default/custom/Inchoo_Heared4us.zip.ZIP, period.

  13. Option is not adding to order when use paypal standard as payment method… can help??? 🙂 It shows in order in admin when i put order from money order method…

  14. How can I add the custom attribute to the new order form in the admin?
    I want to be able to use this field when creating new orders.

  15. have u installed and getting front end screen? please add table column manually ‘sales_flat_order’ .u will definitly get the value on order form (from backend ).

  16. Got it to work…followed Terracides steps
    Well.. I got it working finally, using magento 1.4.1.1

    Here are the steps i followed

    1) System > Configuration > Design and write down “custom” under Admin theme section.

    2) Follow Michael’s instructions above, by modifying the mysql4-install-01.0.php.

    3) Add “heard4us” in the sales_flat_order table.
    ALTER TABLE sales_flat_order ADD heared4us text;

    This should get you going. I hope this will be helpful to someone in the future

    ____
    There is a typo in michaels edit to the SQL file….Reply the $row = line with

    $row = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’)->addColumn(Mage::getSingleton(‘core/resource’)->getTableName(‘sales/order’), ‘giftaid’, ‘TEXT NULL’);

  17. It is good module but I have done all things however it does not show on admin panel plz solve this problem on magenot 1.4.0.1

  18. Well.. I got it working finally, using magento 1.4.1.1

    Here are the steps i followed

    1) System > Configuration > Design and write down “custom” under Admin theme section.

    2) Follow Michael’s instructions above, by modifying the mysql4-install-01.0.php.

    3) Add “heard4us” in the sales_flat_order table.
    ALTER TABLE sales_flat_order ADD heared4us text;

    This should get you going. I hope this will be helpful to someone in the future

  19. I added the heared4us column using

    ALTER sales_flat_order
    ADD heared4us text

    but it’s still not saving in the database

  20. Hey,

    I am also using 1.4.1 and I cannot see the data in the “where did you hearded for us” information in the admin section.

    There is a div for it, but no data. I was wondering if there was a fix for this.

    Thanks

  21. Sorry (: Not Working on Admin Panel

    I have added

    Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’)->addColumn(Mage::getSingleton(‘core/resource’)->getTableName(‘sales/order’), ‘giftaid’, ‘TEXT NULL’);

    in nysql4-install-01.0.php

    Please help me

  22. Hello Nayan,
    Make sure that it is adding the new column in that table .. read the above comment for the adding column to the table using this :
    Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’)->addColumn(Mage::getSingleton(‘core/resource’)->getTableName(‘sales/order’), ‘giftaid’, ‘TEXT NULL’);
    Thanks to Michael… than it should work..

  23. Sorry Yogendra, Still Not working , i have done all the steps you have ordered and also checked `sales_flat_order` table. but not find thing for Heard4us module……

    Please help me.

    Thanks

  24. Naya,

    its working for me in 1.4.1 and even I improved this extension very much as I commented above ..
    just make sure that you have set the admin theme from admin panel.. go to system > configuration > design > admin theme , type there custom and you should be able to see it.. also double check that value is storing in database that is sales_flat_order table..

    Yogi

  25. Thanks For Great Module, but there is some version compatibility issue , i m Magento Version 1.4.1.

    Sorry this is not workking when i show deatils in magento admin panel sales order

  26. Thank you for this extension, it works good on 1.4.0.1.

    But.
    Some users, who use Safari on Mac report us that they cannot checkout. After adding their credit card information, they see doubled “heared for us” tab and cannot move ahead.

    Does anybody have the same problem?

  27. Hi All,
    First of all very much thanks for providing support to this topic as
    I have made it working under 1.4 .. just curious to know if someone have try to get it working in back end while creating new order .. as I have start to work on it..
    Will update soon
    Thanks,

  28. Hi, we also have the same problem with 1.4.1.1 (no value in the AP).
    Is there anyone that has solved this problem?

    Also i would like to thank the creator of this extension for his fine work!!

  29. Hi, I am too on 1.4.1.1 and it is not displaying the value in admin panel.. infact I am trying to get it working using both method .. but no success…

    Here what I am trying
    $addtionalData = array(“heared4us” => $_heared4us_data,”deliveryinstruction”=>$deliveryinstruction);
    $payment = $order->getPayment();
    $payment->setAdditionalData($additionalData)->save();
    and in view.phtml trying this :
    $payment = $_order->getPayment();
    print_r( “this should come”.$additonalData = $payment->getData(‘additional_information’));
    echo “”.$additionalData[“heared4us”].””.$additionalData[“deliveryinstruction”];
    but it is displaying nothing.. anyone can shed light on this?
    Many Thanks 🙂

  30. I.m using magento v.1.4.1.0, and I also can’t see values in AP. Diana’s and Michael’s methods doesn’t work (or maybe I’m doing sth wrong).

  31. fixed it for magento 1.4.1 in the sql setup file replace

    //START Add order attribute by Branko Ajzele
    $sql = "SELECT entity_type_id FROM ".$this->getTable('eav_entity_type')." WHERE entity_type_code='order'";
    $row = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchRow($sql);
    
    $attribute  = array(
    	'type'			=> 'text',
    	'label'			=> 'Heared4us',
    	'visible'		=> false,
    	'required'		=> false,
    	'user_defined'	=> false,
    	'searchable'	=> false,
    	'filterable'	=> false,
    	'comparable'	=> false,
    );
    
    $installer->addAttribute($row['entity_type_id'], 'heared4us', $attribute);
    //END Add customer attribute Branko Ajzele

    with the following line:

    Mage::getSingleton('core/resource')->getConnection('core_read')->addColumn(Mage::getSingleton('core/resource')->getTableName('sales/order'), 'giftaid', 'TEXT NULL');

    The reason for nthis change is that the eav data representation to a flat database

  32. For Pablo and tuba, the reason the information is not showing in the admin is because it is never actually saved in the database.
    Magento 1.4.1.0 has changed the database layout, and the table “sales_order_entity_text” where the “heared4us” attribute is supposed to be saved doesn’t exist anymore.

    As a fast fix, you can add the information to payment/additional_information like this (in app/code/local/Inchoo/Heared4us/Model/Observer.php):

    $payment = $order->getPayment();
    $payment->setAdditionalData($additionalData)->save();

    $additionalData is an array so you might want to format it like this ([heared4us] => “Data”).

    in app/design/adminhtml/default/default/template/sales/order/view/info.phtml

    instead of $_order->getData(‘heared4us’)
    do:

    $payment = $_order->getPayment();
    $additonalData = $payment->getData(‘additional_information’);

    And that’s it. Hope it helps.

  33. How can we add another field under default drop down field on new tab ? Also how can we show additional filed value in admin sales order section ? Please guide us on this asap.

  34. I can’t see the data on the order in the admin.
    I am getting the new tab with option in the checkout.
    Is there a way to check in the db that the info was saved?
    Thanks.

  35. also had a problem at first extracting, but got it to work after switching browsers, now trying to find out where to correct the spelling of the tab from heared , to how you heard about us. any suggestions?

  36. go it to work in magneto 1.4 after i had given up on the admin theme section from appearing. but then it just magically showed up. i guess magneto is robust and it just takes a while for things to show sometimes.

  37. Finally I was able to print the ‘getHeared4us’ in the email as well.

    Here is how:

    In the file: app/code/core/Mage/Sales/Model/Order.php

    Added one more array att. below the line:

    ‘payment_html’ => $paymentBlock->toHtml(),
    ‘heared4us’ => Mage::getSingleton(‘core/session’)->getInchooHeared4us(),

    So now in the ‘order_new’ email it can be printed this way:

    {{var heared4us}}

  38. Hello Branko,

    First of all very much thanks for such a nice module and I got it working too.. I have only one concern is that my client don’t use any Free Payment method and as far as I am sure that your module needs free payment methods like check / money order… so is there any way to avoid this error? as I get is usually when I disable the payment method.. and this is the errror in system log : DEBUG (7): NOT Showing Free payment method..

    Many Thanks,
    Yogendra

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.