Prestashop 1.7 add Fields in contact us form

2.6k Views Asked by At

I had a little problem on Prestashop 1.7.2.0, I want to add some field in my contact us form but don't know how to proceed. I just find tuto for PS 1.6.

If someone could help me.

Thanks a lot

1

There are 1 best solutions below

0
On

Here a no update resistant solution to add a field Name:

I tried the following thing to add a field (and remember this solution is not update proof and the additional fields are not safed in the backoffice):

Update contact.html + contact.txt in the theme/mails folder:

<span style="color:#333"><strong>Name: {contactname}</strong></span><br /><br />

Add the contactname line to the $var_list array in the file contactform.php located in the modules/contactform folder:

$var_list = [
'{order_name}' => '-',
'{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)),
'{email}' =>  $from,
'{product_name}' => '',
'{contactname}' => Tools::nl2br(stripslashes($contactname)),
];

Add a line to the beginning of the function sendMessage(){ in the same file (contactform.php)

$contactname = trim(Tools::getValue('contactname'));

Add the following lines to the part in the file contactform.tpl located in the theme/modules/contactform/views/template/widget folder:

<div class="form-group row">
<label class="col-md-3 form-control-label">{l s='Name' d='Shop.Forms.Labels'}</label>
<div class="col-md-6">
<input
class="form-control"
name="contactname"
type="text"
value="{$contact.contactname}"
placeholder="{l s='Ihr Name' d='Shop.Forms.Help'}"
>
</div>
</div>

I know it's ugly, but hey, it's a start :) as soon as prestashop 1.7 is not buggy anymore I will start programming with proper overrides/modules