Contact Forms

LemonStand allows you to add contact forms to any page of your website. This allows your customers to easily send you email messages, which are sent using an Email Template.

How can I use a Contact Form?

Contact email forms must contain email, name and message fields, but you can also add as many other custom contact form fields as you want!

Most LemonStand themes come with a basic contact form built in, but you can place your own contact form, or even multiple forms, on any page of your online store! The Tutorial tab explains that in detail.

Contact-Form-Settings-2016-03-17-15-37-1


What We'll Cover

Adding a contact form

To add a contact form to your LemonStand website, you will add code for the contact form to any page you want it to appear. You could also add it to a partial, and then call this partial from a template, page and content block.

Contact forms use the system:onSendMessage AJAX handler. Here's an example of a simple contact form:

{{ open_form({'data-ajax-handler': 'system:onSendMessage'}) }}
    <div class="row">
        <div class="twelve columns">
            <label for="contact_email">E-mail Address *
            <input type="text" id="contact_email" name="fields[email]" value="">
            <span class="error">
    <div class="row">
        <div class="twelve columns">
            <label for="contact_name">Your Name *
            <input type="text" id="contact_name" name="fields[name]" value="">
            <span class="error">
    <div class="row">
        <div class="twelve columns">
            <label for="contact_message">Message *
            <textarea type="text" id="contact_message" name="fields[message]" value="" rows="10">
            <span class="error">
    <input type="text" name="hp" value="" style="display: none">
    <input type="submit" class="button" value="Submit">
{{ close_form() }}

The emailname and message fields are required.

You may notice the hp input in the form code above. This implements the honeypot anti-spam solution.

Custom Contact Form Fields

You can add as many custom fields to any LemonStand contact form! Here's an example:

...
<label for="custom_field">Custom field</label>
<input type="text" id="custom_field" name="fields[My custom field]" value=""/>
<span class="error"/>

Custom fields can be required. To make a custom field required it should be added to the Required Fields list on the Contact Form settings page:

Email Templates

By default, the system:contact-message email template is used for sending contact form notifications. It's possible to use another template or use multiple contact forms that each send notifications using different email templates.

The email template name can be supplied in a hidden field called template:

    ...
    <input type="hidden" name="template" value="system:custom-contact-form-template"/>
    <input type="submit" class="button" value="Submit"/>
    {{ close_form() }}

Subject lines

The subject line can be overridden as well, with the subject hidden field:

    ...
    <input type="hidden" name="subject" value="Custom subject"/>
    <input type="submit" class="button" value="Submit"/>
    {{ close_form() }}

Redirect and success messages

When the form is sent, the page refreshes and a confirmation success message is displayed. The redirection URL and the confirmation text can be set with the redirect and successMessage hidden fields:

    ...
    <input type="hidden" name="redirect" value="/message-sent"/>
    <input type="hidden" name="successMessage" value="Your message has been sent. Thank you!"/>
    <input type="submit" class="button" value="Submit"/>
    {{ close_form() }}

Email notification template

The system:contact-message email template is installed by default, but you can set up more contact form email templates as well.

Inside this template, any contact form field defined as fields[name] in the contact form is accessible by its name. The {{ customFields }}variable outputs all the custom fields. Default email template with variables text:

<p>Hello!</p>
<p>A visitor {{ name }} ({{ email }}) has sent a message from the contact form:</p>
<blockquote>{{ message }}</blockquote>
{{ customFields|raw }}