Contact Form in Magento

Contact Form in Magento

As you know, Magento has a built-in contact form that can be used for general contacts. That form isn’t part of any CMS page, you cannot edit some introduction text, you cannot add phone numbers administration, and you cannot see the breadcrumbs. If you wish to edit text in that default contact form, you will need to update front-end files. Luckily, there is an alternative.

Note:You might notice that this is one of our oldest posts. Upon writing we made one error in the code that was never corrected. Now, this post article is updated and we have fully working instructions. Hope this will help.

If you are a developer, editing your contact form HTML is an easy task. You only need to open file:
app/design/frontend/default/[yourtheme]/template/contacts/form.phtml and you will find your way around.

Once there, you will basically edit the layout of this interface.

However, there are cases when you would like to give your client an option to edit some intro text, edit his phone numbers, edit text behind the form, etc. You are probably guessing that it would be nice to be able to embed contact form in some CMS page. No problem.

  • Go to your CMS> Manage Pages interface
  • Once there, input your HTML as you normally would on any other page
  • Once you are happy with HTML part, add this lines:
    <!– CONTACT FORM –>
    {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}
    <!– END OF CONTACT FORM –>

Important note: When you copy/paste the code, it is important to know that WordPress saves the quotes in some weird way, so you should replate the pasted quotes and reenter them.

You will notice that we added xml attribute form_action=”/contacts/index/post”. With it we set form action, and your contact form will work properly. Here is how it looks like. Notice the breadcrumbs.

Contact Form

I know that this is not some breakthrough article, but I will certanly create contact CMS page on all of my future Magento projects.

Hope this was helpful. In case you need some help regarding Magento Development, we would be happy to help. Our team of experts would love to review your code and offer insights on improving your store. Our Magento Technical Audit is a great way to start – feel free to contact us!

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

Out of the box Form Validation in Magento Petar Sambolek
Petar Sambolek, | 24

Out of the box Form Validation in Magento

Magento form field AJAX validation Branko Ajzele
Branko Ajzele, | 8

Magento form field AJAX validation

Problems with Contact form Vanja Devcic
Vanja Devcic, | 17

Problems with Contact form

114 comments

  1. Thank you for your well-explained tutorial.
    However, Contact Form 7 shows up in the WP preview, however, the form does not show up on the webpage.
    Thank you!

  2. Hi,
    Its good post. but there is a minor update in your content
    ” Important note: When you copy/paste the code, it is important to know that WordPress saves the quotes in some weird way, so you should replate the pasted quotes and reenter them.”

    Is this WordPress or Magento?

  3. Really helpful.

    is there any way to email all cart product to store admin… just like an inquiry?

  4. The emails are going to the customer and admin, but the admin is not able to reply to the customer.
    The “reply-to” field is filled with the admin email.
    How to change it ??
    Please assist !!

  5. I get a 404 page when the form submits, it takes me to /contacts/index/post

    I’ve added the form as per your example code as well.

  6. How can I manage the redirect after a message is sent?
    By default it redirects to the default and wrong contact page.

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.