Append custom field in contactus form of Magento
Append custom field in contactus form of Magento

Magento doesn’t have more fields in contact us form.It has some limited field in contact us form. This is the most important section for customer because in this section a user can be easily communicate with store owners. But all the fields available is not sufficient for user as well store owner. So they need some extra fields to add over there. Like Gender dropdown, query category etc. So that purpose of contact can be easily identified. Now I am going to show, how to add some extra fields. Its a very easy steps because we are not going to either any attributes or any custom fields into database table. We will just add some form fields and use those fields name in email template. Is not very simply to Append custom field in contactus form of Magento.

In first step I will just add some elements to contact us form. So please check below details.

Dir: app/design/frontend/[package]/[theme]/template/contacts/form.phtml

Here I just wanna to add an extra dropdown field that is called as category to identify for which this contact information is belongs to. So I have added just above the div of name text box like:

code
And then the challenging part is how can we get this extra filed value. No problem we can get that easily as easily we add here as field.So for that what we need to do ? We can do this by email template because in this can we are not using any data base connectivity.connectivity. Magento just simply takes the form value and send those through email template for that we will just override the email template through transaction email and set our custom template . lets see below details how we can do that .

Login to admin dash board then go by system => transaction email and follow the below steps:

Click on Add New Template on top right and do following steps

  • select contact form from template drop-down
  • click on load template button
  • write the template name as “custom email template”
  • In template content section add this variable Category: {{var data.category}}

This will looks like below image

Settings for creating custom contact us email template
Settings for creating custom contact us email template

Now we have added out custom fields value to transaction email . As we are using custom email template then we have to assigne this to contact us email template . So please check below details for doing this
Navigate: system => configuration => contact => click on email option section and select email template from drop-down of Email Template

Please see below image for full details

Settings for selecting contact us email template
Settings for selecting contact us email template

Like wise you can create any other fields and pass through transaction email template for email.

Hope you utilize you time by reading this article (Append custom field in contactus form of Magento). If yes please give some comment or share to help others

Thank You

Append custom field in contactus form of Magento
The following two tabs change content below.
Jyotiranjan is one of passionate programmer who has been working in magento since 4 years and in the mean time he has developed enormous amount of modules and customization of sites.He loves to write blogs and travel for long journeying.
Tagged on:                 

Leave a Reply

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