One of our most recent projects required us to get a grip on the Magento e-commerce platform. The client was request a “How did you hear about us” feature on the Magento onepage checkout form. Rather than spend the time to learn exactly how Magento is setup and learn a new flavor of PHP, we figured a module would be best. Luckily, we found free module that did the trick!
Inchoo is the company that created this module. The module essentially places a drop down option by default under it’s own tab in the Magento onepage checkout.
Here is an example of the default usage of this module:

In order to get this module to work properly in Magento 1.5, we need to edit some files.
Configuration
First, we need to download the extension and unzip the files. Open your favorite FTP client and drag and drop the files into the root directory of your Magento 1.5 installation.
Once the extension is in place, log into the admin side of Magento and navigate to System > Configuration > Design > Admin Theme. We need to enter in custom into the admin theme field and save.
Once that is done, we need to dig around in the files to make this extension compatible with our English-speaking users and allow the extension to actually work!.
Our first matter of business is we need to change the text which appears on the onepage checkout form. Go to app/code/local/Inchoo/Heared4us/Block/Onepage/heard4us.phtml
Change this:
1 2 3 4 | $this->getCheckout()->setStepData('heared4us', array( 'label' => Mage::helper('checkout')->__('Where did you heared for us'), 'is_show' => true )); |
To this:
1 2 3 4 | $this->getCheckout()->setStepData('heared4us', array( 'label' => Mage::helper('checkout')->__('How did you hear about us?'), 'is_show' => true )); |
Next, we want to alter the text in the admin view to display correctly. Open app/design/adminhtml/default/custom/template/sales/order/view/info.phtml
Around line 134 (if you have line numbers, if not then search for “Where did you heared about us”) we want to replace this:
1 | <h4 class="icon-head head-heared4us"><?php echo Mage::helper('sales')->__('Where did you heared about us') ?></h4> |
With this:
1 | <h4 class="icon-head head-heared4us"><?php echo Mage::helper('sales')->__('How did you hear about us?') ?></h4> |
The code above will change the text on the checkout form with proper English syntax and grammar…
Open your favorite IDE or text-editing program (notpad or textedit) so we can edit this code.
Note: if you don’t have access to edit the files before you place them on the server then edit the files on your local system and then upload them to the server.
One of the first lines of PHP code we will see is the following:
1 2 3 4 5 6 7 8 9 10 | <?php $_options = array( $this->__('Unterwasserwelt.de'), $this->__('Sea Star Online'), $this->__('Sea Star Magazine'), $this->__('Google'), $this->__('YouTube'), $this->__('Referral') ); ?> |
This block of code controls the items that are in our drop down menu on the onepage checkout form. If you would like to use this drop down, the continue on reading how to customize it. If you would like to use a text field, then click here
Editing these drop down items is very easy. All we have to do is replace the text between the ‘ and ‘ inside of the parenthesis. For example:
1 2 3 4 5 6 7 8 9 10 11 | <?php $_options = array( $this->__('A Friend'), $this->__('Twitter'), $this->__('Facebook'), $this->__('Google'), $this->__('YouTube'), $this->__('Referral'), $this->__('Saw it in a Store') ); ?> |
We edited the text to suit our needs and we even added an option to the drop down. It’s important that each item in the array have a comma after it with the exception of the last item in the array. Be sure the structure is always as follows:
1 2 3 4 5 6 | $_options = array( $this->__('Item 1'), //first item, $this->__('Item 2'), //second item, many more items, $this->__('Item 100), //100th item, $this->__('Last Item') //final item (no comma after this) ); |
If you want a text field where the user can enter in their information just like this:
Then we only need a few minor tweaks before we can achieve this feature!
First, we need to comment out the array which contains our drop down menu options.
1 2 3 4 5 6 7 8 9 10 11 | <?php /*$_options = array( $this->__('Unterwasserwelt.de'), $this->__('Sea Star Online'), $this->__('Sea Star Magazine'), $this->__('Google'), $this->__('YouTube'), $this->__('Referral') );*/ $_options = ''; ?> |
Next, we want to comment out the drop down menu itself:
1 2 3 4 5 6 7 8 | <?php /* <select id="getvoice" name="getvoice"> <?php foreach($_options as $_option): ?> <option value="<?php echo $_option ?>"><?php echo $_option ?></option> <?php endforeach; ?> <option id="getvoice-other" value="<?php echo $this->__('Other') ?>"><?php echo $this->__('Other') ?></option> </select> */ ?> |
Finally, we want to put in our text input field, here is an example:
1 2 3 4 | <div class="field"> <div class="field-label"><label for="getvoice">How did you hear about us?<em>*</em></label></div> <div class="field-field"><input type="text" name="getvoice" id="getvoice" /></div> </div> |
Note: there are extra div’s in here that were created for formatting purposes. Here is the css that wwas used to style this field. If you decide to use this css, be sure to put it in /skin/frontend/default/yourtheme/css/skin.css
1 2 3 | #checkoutSteps #opc-heared4us .field {width:100%;} #checkoutSteps #opc-heared4us .field .field-label {font-weight:bold; color:#00c4ff;} #checkoutSteps #opc-heared4us .field .field-label em {color:red;} |
Typically, it’s good just to keep the variable set to an empty string, you never know if it is being used by something else and an error will occur.
Getting the Values to show in the Admin Area
There are few things we must do in order to enable either of options or the user input value to show in the admin side. We must navigate to app/code/local/Inchoo/Heared4us/sql/mysql4-install-0.1.0.php and open the file with your favorite IDE of text editor.
Replace this line:
1 | $row = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchRow($sql); |
with this
1 | $row = Mage::getSingleton('core/resource')->getConnection('core_read')->addColumn(Mage::getSingleton('core/resource')->getTableName('sales/order'), 'giftaid', 'TEXT NULL'); |
Next, we need to add a new field to a table so we need database access with a tool like phpMyAdmin. If you do not have database then contact your administrator and request the following change.
1 | ALTER TABLE sales_flat_order ADD heared4us TEXT; |
If you do have database access with phpMyAdmin, select your magento database and click on the SQL field. Copy and paste the SQL above and then press “Go”. See the image for details.
The end result should be under each new order. You will see a “How did you hear about us?” field and the option/text the user typed in will show as follows:


I do not see an option to change the admin theme in magento 1.5.1
Clear Magento cache
Hello, the plugin specified may not work with Magento 1.5.1.0. I wrote this for Magento 1.5.0.1. At any rate, the admin theme option should be under System > Config > Design > Admin Theme (under Package). You’d want to call it “custom” in the Admin Theme option.
Thanks for a detailed description. I forgot to add the tables in DB. When I saw it step by step I could recognize my faults.
But if I need to show the tab only for Virtual Products how would I able to do it?
Thanks in advance.
Can anyone confirm that this does not work in 1.5.1? Or does it? @Sanmaya , did you use 1.5.1?
I have this working properly (eg I can see the value entered on the admin panel), but only for the check/money order payment method. For paypal website payments std, it doesn’t seem to write the value to the db.
Anyone got any ideas?
Hi peeps i have installed this on my site all is working apart from nothing shows on the order form in admin?? i have gone over this install instructions 5 times now and i cant for the life of me understand why i think it has something to do with my mysql4-install-0.1.0 file here is the code
/////////////////////////////////////////////////////
startSetup();
//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’)->addColumn(Mage::getSingleton(‘core/resource’)->getTableName(‘sales/order’), ‘giftaid’, ‘TEXT NULL’);
$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
$installer->endSetup();
/////////////////////////////////////////////////////
Can anyone tell me why i can not see the text on the order form the space is there just no text any help would be very grateful Thanks
Guys I am at my wits end. I did everything above and when I try to log in to admin area after clearing cache I get an error.
I’m using version 1.6.1
Please help
works fine in 1.6.1 for me. How can I make this required ? As of right now you can just click continue and not have to answer any questions.
Hi everyone, we are in the process of testing this with the most recent version of magento and we will explain in a separate tutorial if there are any drastic changes. We will attempt to figure out how to make this field required. Thanks for your patience.
it works.
but now: how do I get it into the order-confirmation-email?
it is not in the var order collection.
I tried a lot in ..Mage/core/model/email/Template.php , but no result.