Unleash the Full Potential of Your PrestaShop Store

Welcome to MyPresta.eu – Your reliable partner in the e-commerce world. Find innovative modules that will take your business to a new level.

New contact fields in PrestaShop contact form

26.06.2020

In this short guide i will point you a steps to add new fields in default prestashop's contact form page. Thanks to this tutorial your contact form will have additional fields "name, company name, phone". But of course you can use any number of own fields.

 

new contact form fields in prestashop 1.7

 

Adding new fields in PrestaShop 1.7 contact form

  • please open this file: /modules/contactform/views/templates/widget/contactform.tpl or if exists: /themes/your-theme/modules/contactform/views/templates/widget/contactform.tpl
  • add there code to support new fields like i attached below
            <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="name" placeholder="{l s='Your name' d='Shop.Forms.Labels'}">
              </div>
            </div>
            <div class="form-group row">
              <label class="col-md-3 form-control-label">{l s='Company name' d='Shop.Forms.Labels'}</label>
              <div class="col-md-6">
                <input class="form-control" name="company" placeholder="{l s='Company name' d='Shop.Forms.Labels'}">
              </div>
            </div>
            <div class="form-group row">
              <label class="col-md-3 form-control-label">{l s='Phone' d='Shop.Forms.Labels'}</label>
              <div class="col-md-6">
                <input class="form-control" name="phone" placeholder="12-123456789">
              </div>
            </div>
  • Then open file: /modules/contactform/contactform.php
  • there is a line with code:  
    $message = trim(Tools::getValue('message'));
  • replace it with:
    $message = $this->l('Name:'). ' '.trim(Tools::getValue('name')) . '<br/>' . $this->l('Company name:'). ' '.trim(Tools::getValue('company')) . '<br/>' . $this->l('Phone:' ). ' ' . trim(Tools::getValue('phone')) . '<br/>' . trim(Tools::getValue('message'));
  • save changes



that's all!
from now your contact from will support new fields and these additional informations will be delivered with message.

best regards
milos

Zdjęcie autora: Milosz Myszczuk

Artykuł napisany przez Milosza Myszczuka, eksperta PrestaShop i oficjalnego moderatora społeczności PrestaShop. CEO i założyciel agencji interaktywnej VEKIA. Dowiedz się więcej.

If you like this article, support our work!

Comments