midana Posted December 12, 2013 Share Posted December 12, 2013 I have tried a guide of doing this previously but it didn't work. Think the cause could have been that it was dated. Does anyone know good links or information of how to add functioning fields to the Prestashop contact form? Would like to add a field for name and phone number to it. Link to comment Share on other sites More sharing options...
tdr170 Posted December 12, 2013 Share Posted December 12, 2013 (edited) Here is a tutorial on just that I have used for years, if you follow exactly should be no problem. First edit ..themes/yourtheme/contact-form.tpl add below just above: <p class="text"> <label for ="email"> <p class="text"> <label for="contactperson">{l s='Name'}</label> <input type="text" id="contactperson" name="contactperson" value="{if isset($contactperson)}{$contactperson|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> <p class="text"> <label for="phonenumber">{l s='Phone Number'}</label> <input type="text" id="phonenumber" name="phonenumber" value="{if isset($phonenumber)}{$phonenumber|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </p> Now edit ContactController.php In 1.4 controllers/ContactController.php in 1.5 controllers/front/ContactController.php Add below just after: $this->errors[] = Tools::displayError('Bad file extension'); elseif (!empty($_FILES['fileUpload']['name']) AND !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) AND !in_array(substr($_FILES['fileUpload']['name'], -5), $extension)) $this->errors[] = Tools::displayError('Bad file extension'); elseif (!($contactperson = nl2br2(Tools::getValue('contactperson')))) $this->errors[] = Tools::displayError('Name cannot be blank'); elseif (!($phonenumber = nl2br2(Tools::getValue('phonenumber')))) $this->errors[] = Tools::displayError('Phone Number cannot be blank'); else { Then change the following: change this: if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]', $var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) || !Mail::Send($this->context->language->id, 'contact_form', ((isset($ct) && Validate::isLoadedObject($ct)) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent')), $var_list, $from, null, $contact->email, $contact->name, $fileAttachment)) $this->errors[] = Tools::displayError('An error occurred while sending the message.'); To this: if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message), '{contactperson}' => stripslashes ( $contactperson ),'{phonenumber}' => stripslashes ( $phonenumber )), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{email}' => $from, '{message}' => stripslashes($message), '{contactperson}' => stripslashes ( $contactperson ),'{phonenumber}' => stripslashes ( $phonenumber )), $from)) self::$smarty->assign('confirmation', 1); else $this->errors[] = Tools::displayError('An error occurred while sending message.'); Change this: (For 1.4xx only) if (empty($contact->email)) Mail::Send((int)self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent', (int)self::$cookie->id_lang), array('{message}' => stripslashes($message)), $from); self::$smarty->assign('confirmation', 1); To this: if (empty($contact->email)) Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message),'{contactperson}' => stripslashes ( $contactperson ),'{phonenumber}' => stripslashes ( $phonenumber )), $from); self::$smarty->assign('confirmation', 1); Last we need to add the fileds to the contact.html mail, (mails/en/contact.html & contact.txt) to contact.html <tr> <td align="left">Name: {contactperson} <br><br> Phone Number: {phonenumber}</td> </tr> to contact.txt Name: {contactperson} Phone #: {phonenumber} Here is a pic of my 1.5 test site: Edited December 17, 2013 by tdr170 (see edit history) 2 Link to comment Share on other sites More sharing options...
midana Posted December 17, 2013 Author Share Posted December 17, 2013 I don't find this one in my contactcontroller: if (Mail::Send((int)self::$cookie->id_lang, 'contact', Mail::l('Message from contact form', (int)self::$cookie->id_lang), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) AND Mail::Send((int)self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent', (int)self::$cookie->id_lang), array('{message}' => stripslashes($message)), $from)) self::$smarty->assign('confirmation', 1); else $this->errors[] = Tools::displayError('An error occurred while sending message.'); I have this, what should I add to it and where? (if I copied the right text) if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]', $var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) || !Mail::Send($this->context->language->id, 'contact_form', ((isset($ct) && Validate::isLoadedObject($ct)) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent')), $var_list, $from, null, $contact->email, $contact->name, $fileAttachment)) $this->errors[] = Tools::displayError('An error occurred while sending the message.'); } } Thank you so much for helping me. Link to comment Share on other sites More sharing options...
tdr170 Posted December 17, 2013 Share Posted December 17, 2013 The text I posted is from 1.4 but works just as well with 1.5 the lines needing the change are 197-201 change as above. (I updated the post for better understanding) Link to comment Share on other sites More sharing options...
midana Posted January 7, 2014 Author Share Posted January 7, 2014 Thank you very much, it works! However, the new fields informations doesn't show up when i check the message in admin. :S Link to comment Share on other sites More sharing options...
tdr170 Posted January 8, 2014 Share Posted January 8, 2014 (edited) I just tested this in my 1.5.6 test site and the message sent from the contact form shows without any problems in my customer service section of the BO. Edited January 8, 2014 by tdr170 (see edit history) Link to comment Share on other sites More sharing options...
midana Posted January 10, 2014 Author Share Posted January 10, 2014 Does the new fields content show up as well? Link to comment Share on other sites More sharing options...
Guest presta06 Posted February 10, 2014 Share Posted February 10, 2014 Hi I want also to have two more fields in contact form, sending email is working, but i want to see it in backoffice also. I added in AdminCustomerThreadsController.php 'contactperson' => array( 'title' => $this->l('Contact Person'), 'width' => 100, 'filter_key' => 'contactperson', 'tmpTableFilter' => true, ), 'phonenumber' => array( 'title' => $this->l('Phone number'), 'width' => 100, 'filter_key' => 'phonenumber', 'tmpTableFilter' => true, ), In table customer_message I added two fields phonenumber and contactperson. Now I can get information from database, but i dont know what to do to insert into database new information from contact form. Can anybody help? Link to comment Share on other sites More sharing options...
ajay21 Posted June 9, 2014 Share Posted June 9, 2014 i am not able to change code in 1.5.3.1 version...... please help me Link to comment Share on other sites More sharing options...
jeandelima Posted October 2, 2014 Share Posted October 2, 2014 Working perfectly. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now