Jump to content

HELP!! adding fields to contact us page - email alert configuration


Recommended Posts

Hi,
I'm having some problems adding fields to my contact us page. I have edited the contact-form.tpl to include the fields Phone number and how you heard about us:

 

{l s='Phone number'}
           <input type="text" id="phone" name="phone" />



{l s='How did you hear about us?'}
           <input type="text" id="source" name="source" />




When I recieve the email notification of the enquiry, my new fields are not showing up. They just show the field id.

Message from your shop Topstitched

E-mail address: [email protected]

Phone: {phone}

Where did you hear about us?: {source}

Message: Hello



Any ideas on how to fix it?
Link to comment
Share on other sites

Update: I found another thread that talks about this problem and tries to offer a solution:

http://www.prestashop.com/forums/viewthread/11123/modules/creation_of_new_fields_in_the_contact_form

Tried it myself and followed instructions to the dot - but did not work.

Has anyone else tried to alter the contact us form?

I will post my code for the following three items that are relavant:

1. contact-form.php (in your prestashop’s root directory)
2. contact-form.tpl (in your themes directory)
3. contact.html (yourshopfolder/mails/en/ folder {if thats the language you are using})

Link to comment
Share on other sites

Trying to get the following fields:

Name
E-mail address
Phone number (not a required field)
How did you hear about us? (not a required field)
Message



contact-form.php



<?php



$useSSL = true;



include(dirname(__FILE__).'/config/config.inc.php');

include(dirname(__FILE__).'/header.php');



$errors = array();



$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));



if (Tools::isSubmit('submitMessage'))

{

   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))

       $errors[] = Tools::displayError('Invalid e-mail address');
elseif (!($name = nl2br2(Tools::getValue('name'))))
       $errors[] = Tools::displayError('Name cannot be blank');
       elseif (!($phone = nl2br2(Tools::getValue('phone'))))
       $errors[] = Tools::displayError('Phone cannot be blank');
       elseif (!($source = nl2br2(Tools::getValue('source'))))
       $errors[] = Tools::displayError('Source cannot be blank');
   elseif (!($message = nl2br2(Tools::getValue('message'))))

       $errors[] = Tools::displayError('Message cannot be blank');

   elseif (!Validate::isMessage($message))

       $errors[] = Tools::displayError('invalid message');


   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))

       $errors[] = Tools::displayError('Please select a subject for your message from the list');

   else

   {

       if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email))

           $smarty->assign('confirmation', 1);

       else

           $errors[] = Tools::displayError('An error occurred while sending message');

   }

}

$smarty->assign('errors', $errors);



$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');

include(dirname(__FILE__).'/footer.php');



?>

Link to comment
Share on other sites

contact-form.tpl


>{capture name=path}{l s='Contact'}{/capture}

{include file=$tpl_dir./breadcrumb.tpl}



{l s='Contact Us'}



{if isset($confirmation)}


{l s='Your message has been successfully sent.'}

</pre>
<ul>

{l s='Home'}

</ul>
<br><br>{else}<br><br><p>{l s='Please feel free to contact us with any enquiries that you may have.'}.</p>
<br><br>   {include file=$tpl_dir./errors.tpl}<br><br>   <form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std"><br><br><br><br><h3>{l s='Send a message'}</h3>
<br><br><p>

{l s='Subject'}



{l s='-- Choose --'}

               {foreach from=$contacts item=contact}

{$contact.name|escape:'htmlall':'UTF-8'}

               {/foreach}



</p>
<br><br><p>{l s='Select a subject'}</p>
<br><br>       {foreach from=$contacts item=contact}<br><br><p>

{l s='Description'}{$contact.description|escape:'htmlall':'UTF-8'}</p>
<br><br>       {/foreach}<br><br><p>
{l s='Name'}
           <input type="text" id="name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall'|stripslashes}{/if}" />
</p>
<br><p>

{l s='E-mail address'}

           <input type="text" id="email" name="from" value="{if isset($smarty.post.from)}{$smarty.post.from|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />

</p>
<br><p>

{l s='Phone number'}

           <input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.from|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />

</p>
<br><p>

{l s='How did you hear about us?'}

           <input type="text" id="source" name="source" value="{if isset($smarty.post.source)}{$smarty.post.source|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />

</p>
<br><br><p>

{l s='Message'}

            <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>

</p>
<br><br><p>

           <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" />

</p>
<br><br><br><br></form><br><br>{/if}<br><br><br

Link to comment
Share on other sites

contact.html

>

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <title>Message from {shop_name}</title>
</head>
<body>
</pre>
<table style="font-family:Verdana, sans-serif;font-size:11px;color:#374953;width:550px;">

 Message from your shop {shop_name} 
               E-mail address: {email}



               Name: {name}



               Phone: {phone}



               Where did you hear about us?: {source}



               Message: {message}
 
{shop_name} 
</table>
<br></body><br></html><br

Link to comment
Share on other sites

I did ask first - was told to edit the .php which i tried to no avail - even after hours of searching through other threads in the forum.

I am not too sure where I am going wrong - someone who is more familiar with the contact forms can easily pinpoint where the error may be - thus the code to scan for people who can and are willing to help.

Link to comment
Share on other sites

Hello People,

I have successfully added new fields to the contact form.

And email returns all the values which the user enters in the form.

Please check the following website for a demo.

If anyone requests how an email would be sent.. I will create a contact corresponding to that email address, so that they could see how the email arrives.

http://www.explorersbase.com/store/contact-form.php

Thanks

Link to comment
Share on other sites

Hi Cronos
Nice work on getting the form working. Any help you can give me would be much appreciated.
I need the following fields in my contact form:

Subject
Name
E-mail address
Phone number (not a required field)
How did you hear about us? (not a required field)
Message

Subject, Email and Message (the default settings) are currently working fine. Just need to add Name, Phone and How they heard about us.

Thank you muchly!

Link to comment
Share on other sites

  • 5 months later...

in your php your code should have the following form,

this is a working chunk from my else statement.

hopefully you are able to adapt it to yours.

everything else you are doing seems to be ok.

    else
   {
if ( Mail :: Send ( intval ( $cookie -> id_lang ), 'contact' , 'Message from contact form' , array( '{email}' => $_POST[ 'from' ] , '{message}' => stripslashes ( $message ), '{name}' => stripslashes ( $name ), '{suits_required}' => stripslashes ( $suits_required ),'{kneck}' => stripslashes ( $kneck ),'{chest}' => stripslashes ( $chest ),'{sleeve}' => stripslashes ( $sleeve ),'{waist}' => stripslashes ( $waist ),'{leg}' => stripslashes ( $leg ), '{address}' => stripslashes ( $address ), '{city}' => stripslashes ( $city ), '{postalcode}' => stripslashes ( $postalcode ), '{Country}' => stripslashes ( $Country ), '{telephone}' => $_POST[ 'telephone' ] ), $contact -> email )) 
$smarty -> assign ( 'confirmation' , 1 ); 
       else
           $errors[] = Tools::displayError('An error occurred while sending message');
   }
}

Link to comment
Share on other sites

×
×
  • Create New...