firebird Posted April 12, 2014 Share Posted April 12, 2014 Bonjour, Il existe pas mal de tutos pour l'ajout de champs au formulaire de contact natif des anciennes versions, mais l'architecture a changé avec la version 1.6 Je ne suis pas parvenu à faire l'adaptation. Je suis à la recherche de solutions pour cette nouvelle version. Link to comment Share on other sites More sharing options...
kikiman Posted July 17, 2014 Share Posted July 17, 2014 Up, même problème ici, prestashop 1.6.0.8. Je voudrais juste ajouter un champ n° de téléphone mais en suivant les guide pour les anciennes versions de prestashop, le champ apprait mais n'est pas controller et ni renvoyer dans le mail. Cordialement, Link to comment Share on other sites More sharing options...
fair-agenceweb Posted July 30, 2014 Share Posted July 30, 2014 j'ai le même soucis en 1.6.0.5, modifier le formulaire de contact est une horreur sur prestashop voici le code de mon formulaire dans contact-form.tpl <form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data"> <fieldset> <div class="contL"> <label for="lastname">Votre nom <span class="requis">(obligatoire)</span></label> <input type="text" id="lastname" name="lastname" value="{$customerThread.lastname|escape:'htmlall':'UTF-8'}" /> </div> <div class="contR"> <label for="firstname">Votre prénom <span class="requis">(obligatoire)</span></label> <input type="text" id="firstname" name="firstname" value="{$customerThread.firstname|escape:'htmlall':'UTF-8'}" /> </div> <div class="contL"> <label for="email">{l s='Email address'} <span class="requis">(obligatoire)</span></label> {if isset($customerThread.email)} <input type="text" id="email" name="from" value="{$customerThread.email|escape:'htmlall':'UTF-8'}" readonly /> {else} <input type="text" id="email" name="from" value="{$email|escape:'htmlall':'UTF-8'}" /> {/if} </div> <div class="contR"> <label for="phone">{l s='Votre numéro de téléphone'}</label> <input type="phone" id="phone" name="phone" value="{$customerThread.phone|escape:'htmlall':'UTF-8'}" /> </div> <div class="contL"> <label for="nature">{l s='Vous êtes'}</label> <div class="select"> <select id="nature" name="nature" value="{$customerThread.nature|escape:'htmlall':'UTF-8'}"> <option value="pro">{l s='Un professionnel'}</option> <option value="part">{l s='Un particulier'}</option> </select> </div> </div> <div class="contR"> <label for="id_contact">{l s='Vous souhaitez'}</label> <div class="select"> <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')"> <option value="comptepro">Créer votre compte professionnel</option> <option value="contact">Nous contacter</option> <option value="sav">Signaler un problème avec un article ou une commande</option> <option value="autre">Autre</option> </select> </div> </div> <div class="contL"> <label for="company">{l s='Votre société'}</label> <input type="text" id="company" name="company" value="{$customerThread.company|escape:'htmlall':'UTF-8'}" /> </div> <div class="contR"> <label for="company">{l s='Siren de votre société'}</label> <input type="text" id="siren" name="siren" value="{$customerThread.siren|escape:'htmlall':'UTF-8'}" /> </div> {if !$PS_CATALOG_MODE} {if (!isset($customerThread.id_order) || $customerThread.id_order > 0)} {if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1} <div class="contL"><label for="id_order">{l s='Order reference'}</label><div class="select"><select name="id_order" > <option value="0">{l s='-- Choose --'}</option> {foreach from=$orderList item=order} <option value="{$order.value|intval}" {if $order.selected|intval}selected="selected"{/if}>{$order.label|escape:'htmlall':'UTF-8'}</option> {/foreach} </select></div> </div> {elseif !isset($customerThread.id_order) && !isset($isLogged)} <div class="contF"><label for="id_order">{l s='Order reference'}</label><input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order|intval > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order) && !empty($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" /></div> {elseif $customerThread.id_order|intval > 0} <div class="contL"><label for="id_order">{l s='Order reference'}</label><input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly /></div> {/if} {/if} {if isset($isLogged) && $isLogged} <div class="contR"> <label for="id_product">{l s='Product'}</label> {if !isset($customerThread.id_product)}<div class="select"> {foreach from=$orderedProductList key=id_order item=products name=products} <select name="id_product" id="{$id_order}_order_products" class="product_select" style="{if !$smarty.foreach.products.first} display:none; {/if}" {if !$smarty.foreach.products.first}disabled="disabled" {/if}> <option value="0">{l s='-- Choose --'}</option> {foreach from=$products item=product} <option value="{$product.value|intval}">{$product.label|escape:'htmlall':'UTF-8'}</option> {/foreach} </select> {/foreach}</div></div> {elseif $customerThread.id_product > 0} <div class="contR"><input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly /></div> {/if} {/if} {/if} {if $fileupload == 1} <div class="contF"> <label for="fileUpload">{l s='Attach File'}</label> <input type="hidden" name="MAX_FILE_SIZE" value="2000000" /> <input type="file" name="fileUpload" id="fileUpload" /> </div> {/if} <div class="contF"> <label for="message">{l s='Message'}</label> <textarea id="message" name="message" rows="15" cols="10">{if isset($message)}{$message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea> </div> <div class="contF"> <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" /> </div> </fieldset> </form> mon code dans ContactController.php que j'ai placé dans override/controllers/front class ContactControllerCore extends FrontController { public $php_self = 'contact'; public $ssl = true; /** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { if (Tools::isSubmit('submitMessage')) { $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg'); $fileAttachment = Tools::fileAttachment('fileUpload'); $message = Tools::getValue('message'); // Html entities is not usefull, iscleanHtml check there is no bad html tags. $firstname = Tools::getValue('firstname'); $lastname = Tools::getValue('lastname'); $phone = Tools::getValue('phone'); $nature = Tools::getValue('nature'); $id_contact = Tools::getValue('id_contact'); $company = Tools::getValue('company'); $siren = Tools::getValue('siren'); if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) $this->errors[] = Tools::displayError('Invalid email address.'); else if (!$lastname) $this->errors[] = Tools::displayError('Veuillez renseigner votre nom'); else if (!$firstname) $this->errors[] = Tools::displayError('Veuillez renseigner votre prénom'); else if (!Validate::isCleanHtml($message)) $this->errors[] = Tools::displayError('Invalid message'); else if (!empty($fileAttachment['name']) && $fileAttachment['error'] != 0) $this->errors[] = Tools::displayError('An error occurred during the file-upload process.'); else if (!empty($fileAttachment['name']) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -4)), $extension) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -5)), $extension)) $this->errors[] = Tools::displayError('Bad file extension'); else { $customer = $this->context->customer; if (!$customer->id) $customer->getByEmail($from); $contact = new Contact($id_contact, $this->context->language->id); if (!(( ($id_customer_thread = (int)Tools::getValue('id_customer_thread')) && (int)Db::getInstance()->getValue(' SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL(Tools::getValue('token')).'\'') ) || ( $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order')) ))) { $fields = Db::getInstance()->executeS(' SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email FROM '._DB_PREFIX_.'customer_thread cm WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->id.' AND ('. ($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').' id_order = '.(int)(Tools::getValue('id_order')).')'); $score = 0; foreach ($fields as $key => $row) { $tmp = 0; if ((int)$row['id_customer'] && $row['id_customer'] != $customer->id && $row['email'] != $from) continue; if ($row['id_order'] != 0 && Tools::getValue('id_order') != $row['id_order']) continue; if ($row['email'] == $from) $tmp += 4; if ($row['id_contact'] == $id_contact) $tmp++; if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) $tmp += 2; if ($tmp >= 5 && $tmp >= $score) { $score = $tmp; $id_customer_thread = $row['id_customer_thread']; } } } $old_message = Db::getInstance()->getValue(' SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread) WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->id.' ORDER BY cm.date_add DESC'); if ($old_message == $message) { $this->context->smarty->assign('alreadySent', 1); $contact->email = ''; $contact->customer_service = 0; } if ($contact->customer_service) { if ((int)$id_customer_thread) { $ct = new CustomerThread($id_customer_thread); $ct->status = 'open'; $ct->id_lang = (int)$this->context->language->id; $ct->id_contact = (int)($id_contact); if ($id_order = (int)Tools::getValue('id_order')) $ct->id_order = $id_order; if ($id_product = (int)Tools::getValue('id_product')) $ct->id_product = $id_product; $ct->update(); } else { $ct = new CustomerThread(); if (isset($customer->id)) $ct->id_customer = (int)($customer->id); $ct->id_shop = (int)$this->context->shop->id; if ($id_order = (int)Tools::getValue('id_order')) $ct->id_order = $id_order; if ($id_product = (int)Tools::getValue('id_product')) $ct->id_product = $id_product; $ct->id_contact = (int)($id_contact); $ct->id_lang = (int)$this->context->language->id; $ct->email = $from; $ct->status = 'open'; $ct->token = Tools::passwdGen(12); $ct->add(); } if ($ct->id) { $cm = new CustomerMessage(); $cm->id_customer_thread = $ct->id; $cm->message = $message; if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename']))) $cm->file_name = $fileAttachment['rename']; $cm->ip_address = ip2long(Tools::getRemoteAddr()); $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; if (!$cm->add()) $this->errors[] = Tools::displayError('An error occurred while sending the message.'); } else $this->errors[] = Tools::displayError('An error occurred while sending the message.'); } if (!count($this->errors)) { $var_list = array( '{order_name}' => '-', '{attached_file}' => '-', '{message}' => Tools::nl2br(stripslashes($message)), '{email}' => $from, '{product_name}' => '', ); if (isset($fileAttachment['name'])) $var_list['{attached_file}'] = $fileAttachment['name']; $id_order = (int)Tools::getValue('id_order'); $id_product = (int)Tools::getValue('id_product'); if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) $id_order = $ct->id_order; if ($id_order) { $order = new Order((int)$id_order); $var_list['{order_name}'] = $order->getUniqReference(); $var_list['{id_order}'] = $id_order; } if ($id_product) { $product = new Product((int)$id_product); if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) $var_list['{product_name}'] = $product->name[Context::getContext()->language->id]; } if (empty($contact->email)) 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, null, null, $fileAttachment); else { 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.'); } } if (count($this->errors) > 1) array_unique($this->errors); else $this->context->smarty->assign('confirmation', 1); } } } public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'contact-form.css'); $this->addJS(_THEME_JS_DIR_.'contact-form.js'); $this->addJS(_PS_JS_DIR_.'validate.js'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->assignOrderList(); $email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : ''))); $this->context->smarty->assign(array( 'errors' => $this->errors, 'email' => $email, 'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD') )); if (($id_customer_thread = (int)Tools::getValue('id_customer_thread')) && $token = Tools::getValue('token')) { $customerThread = Db::getInstance()->getRow(' SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL($token).'\' '); $this->context->smarty->assign('customerThread', $customerThread); } $this->context->smarty->assign(array( 'contacts' => Contact::getContacts($this->context->language->id), 'message' => html_entity_decode(Tools::getValue('message')) )); $this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl'); } /** * Assign template vars related to order list and product list ordered by the customer */ protected function assignOrderList() { if ($this->context->customer->isLogged()) { $this->context->smarty->assign('isLogged', 1); $products = array(); $result = Db::getInstance()->executeS(' SELECT id_order FROM '._DB_PREFIX_.'orders WHERE id_customer = '.(int)$this->context->customer->id.' ORDER BY date_add'); $orders = array(); foreach ($result as $row) { $order = new Order($row['id_order']); $date = explode(' ', $order->date_add); $tmp = $order->getProducts(); foreach ($tmp as $key => $val) $products[$row['id_order']][$val['product_id']] = array('value' => $val['product_id'], 'label' => $val['product_name']); $orders[] = array('value' => $order->id, 'label' => $order->getUniqReference().' - '.Tools::displayDate($date[0],null) , 'selected' => (int)Tools::getValue('id_order') == $order->id); } $this->context->smarty->assign('orderList', $orders); $this->context->smarty->assign('orderedProductList', $products); } } } et enfin mon code dans contact_form.html : <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> <title>Message de {shop_name}</title> </head> <body bgcolor="#EEEEEE" style="text-align:center;color:#414141"> <p style="padding:15px 0; margin:0 auto; text-align:center;"><img src="http://localhost:8888/themes/zensation/css/images/salamandre-design-logo.png" width="425px" height="95px" /></p> <table width="500px" align="center" cellpadding="5px" cellspacing="0" border="0"> <tr> <td style="text-align:center">Voici votre message à l'attention du service client de <strong>Salamandre Design</strong></td> </tr> <tr> <td style="background:#fff;">Vous êtes <strong>{nature}</strong></td> </tr> <tr> <td>Vous representez la société <strong>{company}</strong></td> </tr> <tr> <td>Dont le siren est {siren}</td> </tr> <tr> <td style="background:#fff;">Vous souhaitez</td> </tr> <tr> <td style="background:#fff;"><strong>{id_contact}</strong></td> </tr> <tr> <td>Vous nous contactez concernant la commande <strong>{order_name}</strong></td> </tr> <tr> <td style="background:#fff;">et notamment le produit <strong>{product_name}</strong></td> </tr> <tr> <td style="background:#fff;text-align:center">Votre message</td> </tr> <tr> <td style="text-align:center">{message}</td> </tr> <tr> <td style="background:#fff;">Vous avez joint à votre demande</td> </tr> <tr> <td style="background:#fff;">{attached_file}</td> </tr> </table> </body> </html> la plupart de mes données n'apparaissent pas dans mon mail, je ne reçois même pas le mail en tant qu'administrateur. Les problèmes sur les formulaires de contact sont plus que récurrents, à quand une vraie amélioration de ce côté la ? quand seront-ils enfin intégrés au système, ce qui est plutôt basique pour un cms même de type e-shop ? Link to comment Share on other sites More sharing options...
fair-agenceweb Posted August 18, 2014 Share Posted August 18, 2014 je me permets de up ce sujet, quelqu'un a-t'il une solution ? Cordialement, Link to comment Share on other sites More sharing options...
Tijiflox Posted September 15, 2014 Share Posted September 15, 2014 (edited) Bonjour a tous.J'ai a mon avis le meme probleme.J'ai suivi le tuto de Nemo. Je recoit bien les donnees dans ma base de donnees mais cela ne transfert pas au back-office ni meme aux emails.Je suis aussi en v 1.6 et mon furmulaire est a l'addresse suivante: N'hesitez pas a mettre a jour le post.Merci d'avance a tous Edited November 12, 2014 by Tijiflox (see edit history) Link to comment Share on other sites More sharing options...
serialmother Posted April 2, 2015 Share Posted April 2, 2015 Bonsoir, j'aimerais bien avoir une réponse aussi pour la version 1.6 En suivant le tuto Nemo, je ne reçois plus ni mail ni notification... Merci Link to comment Share on other sites More sharing options...
Ilexia Posted February 8, 2016 Share Posted February 8, 2016 Bonjour, Quelqu'un aurait une solution? Merci beaucoup 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