Jump to content

(Résolu) Formulaire contact v 1.5.6 ajout champ et multi-langues


Recommended Posts

Bonjour,

 

Je poste mon problème ici après avoir surfé depuis plusieurs jours afin de trouver un tutoriel montrant comment ajouter des champs au formulaire de contact de la version 1.5.6 de prestashop, il y a des exemples mais que pour de veille version 1.4... donc plus compatible avec la dernière version.... la mouise :(

 

Ce que j'aimerai, c'est d'ajouter plusieurs champ comme, Nom, Prénom, Adresse, Ville, Code postale, Pay et Capcha pour la validation.

 

Dans l'objet du formulaire pouvoir traduire les 2 choix possibles Service client et webmaster comme le reste des label des différents champs.

 

J'espère que vous pourrez m'aider.

Edited by reaman (see edit history)
Link to comment
Share on other sites

Bonjour,

 

Dans l'objet du formulaire pouvoir traduire les 2 choix possibles Service client et webmaster comme le reste des label des différents champs.

 

post-459329-0-92559900-1381502189_thumb.png

 

 

ajouter plusieurs champ comme, Nom, Prénom, Adresse, Ville, Code postale

 

Il faut modifier AdminContactsController.php (dossier prestashop/controllers/admin)

		$this->fields_list = array(
			'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
			'name' => array('title' => $this->l('Title'), 'width' => 130),
			'email' => array('title' => $this->l('Email address'), 'width' => 130),
			'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

et le renderForm

EDIT : Il faut aussi modifier le fichier ContactController.php (dossier prestashop/controllers/front)

Edited by indesign (see edit history)
Link to comment
Share on other sites

Merci indesign pour ta réponse rapide, 

J'aimerai juste savoir comment et quoi modifier dans le fichier ContactController.php ?

 

Je suis en phase de test et de modification sur ma boutique prestashop 1.5.6.0, un truc que je ne comprends pas,

l'envoi de mon formulaire de contact depuis mon serveur de mon pc WampServer 2.4, ne fonctionne pas :(

J'ai bien modifié le fichier ini.php comme suis :

Je suis chez Free

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.free.fr
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]

Puis je fait un test avec une page ou j'ai fait un formulaire et j'envoi via mon adresse email, tout fonctionne bien, je le reçois, donc wampserver est ok.

Puis je regarde dans le BackOffice -> Paramètres avancés -> Emails -> Essai de votre configuration mail et j'envoi le mail test en cliquant sur Envoyer un mail test et tout fonctionne bien, je le reçois aussi.

Donc je ne comprends pas pourquoi depuis le formulaire de contact d'origine cela ne fonctionne pas !?

 

Avez-vous une idée ??

Edited by reaman (see edit history)
Link to comment
Share on other sites

Je suis sous windows 7 ultimate 64 mais les paramètres pour free ne sont que smtp.free.fr port smtp 25 et pop.free.fr  port pop 110.

 

Je regarde là ce que dois modifier dans le fichier ContactController.php (dossier prestashop/controllers/front), j'ai fait la modifications des 2 fichiers  AdminContactsController.php (dossier prestashop/controllers/admin) et contact-form (dossier prestashop/theme/monTheme).

Edited by reaman (see edit history)
Link to comment
Share on other sites

Je parle de ceci : j'ai supprimé mes accès personnel bien sûr. ;)

 

post-459329-0-34215500-1381511906_thumb.png

 

dans  ContactController.php tu trouveras

						if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',

qui appelle la classe Mail.php

	public static function Send($id_lang, $template, $subject, $template_vars, $to,
		$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
		$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
	{
		$configuration = Configuration::getMultiple(array(
			'PS_SHOP_EMAIL',
			'PS_MAIL_METHOD',
			'PS_MAIL_SERVER',
			'PS_MAIL_USER',
			'PS_MAIL_PASSWD',
			'PS_SHOP_NAME',
			'PS_MAIL_SMTP_ENCRYPTION',
			'PS_MAIL_SMTP_PORT',
			'PS_MAIL_TYPE'
		), null, null, $id_shop);
Edited by indesign (see edit history)
Link to comment
Share on other sites

J'ai modifier ainsi mes fichiers 

 

contact-form (dossier prestashop/theme/monTheme)

<p class="text">
	<label for="name">{l s='Name'}</label>
	{if isset($customerThread.name)}
		<input type="text" id="name" name="name" value="{$customerThread.name}" readonly="readonly" />
	{else}
		<input type="text" id="name" name="name" value="{$name}" />
	{/if}
</p>
<p class="text">
	<label for="first_name">{l s='First Name'}</label>
	{if isset($customerThread.first_name)}
		<input type="text" id="first_name" name="first_name" value="{$customerThread.first_name}" readonly="readonly" />
	{else}
		<input type="text" id="first_name" name="first_name" value="{$first_name}" />
	{/if}
</p>
<p class="text">
	<label for="address">{l s='Address'}</label>
	{if isset($customerThread.address)}
		<input type="text" id="address" name="address" value="{$customerThread.address}" readonly="readonly" />
	{else}
		<input type="text" id="address" name="adress" value="{$address}" />
	{/if}
</p>
<p class="text">
	<label for="city">{l s='City'}</label>
	{if isset($customerThread.city)}
	<input type="text" id="city" name="city" value="{$customerThread.city}" readonly="readonly" />
	{else}
		<input type="text" id="city" name="city" value="{$city}" />
	{/if}
</p>
<p class="text">
	<label for="postal_code">{l s='Postal Code'}</label>
	{if isset($customerThread.postal_code)}
		<input type="text" id="postal_code" name="postal_code" value="{$customerThread.postal_code}" readonly="readonly" />
	{else}
		<input type="text" id="postal_code" name="postal_code" value="{$postal_code}" />
	{/if}
</p>

AdminContactsController.php (dossier prestashop/controllers/admin)

$this->fields_list = array(
	'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
	'name' => array('title' => $this->l('Title'), 'width' => 130),
	'first_name' => array('title' => $this->l('Title'), 'width' => 130),
	'address' => array('title' => $this->l('Title'), 'width' => 130),
	'city' => array('title' => $this->l('Title'), 'width' => 130),
	'postal_code' => array('title' => $this->l('Title'), 'width' => 130),
	'email' => array('title' => $this->l('Email address'), 'width' => 130),
	'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

ce qui donne :

 

mini_131011072629299396.jpg

 

 

Ce qui manque la traductiondes labels des cahmps cela doit être dans le BO mais ou ??

et la modification du fichier  ContactController.php (dossier prestashop/controllers/front)

 

 

Link to comment
Share on other sites

Ce qui manque la traduction des labels des champs cela doit être dans le BO mais ou ??

 Remplace

$this->fields_list = array(
	'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
	'name' => array('title' => $this->l('Title'), 'width' => 130),
	'first_name' => array('title' => $this->l('Title'), 'width' => 130),
	'address' => array('title' => $this->l('Title'), 'width' => 130),
	'city' => array('title' => $this->l('Title'), 'width' => 130),
	'postal_code' => array('title' => $this->l('Title'), 'width' => 130),
	'email' => array('title' => $this->l('Email address'), 'width' => 130),
	'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

Par

$this->fields_list = array(
	'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
	'name' => array('title' => $this->l('Name'), 'width' => 130),
	'first_name' => array('title' => $this->l('First name'), 'width' => 130),
	'address' => array('title' => $this->l('Adress'), 'width' => 130),
	'city' => array('title' => $this->l('City'), 'width' => 130),
	'postal_code' => array('title' => $this->l('Postal code'), 'width' => 130),
	'email' => array('title' => $this->l('Email address'), 'width' => 130),
	'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

 

et la modification du fichier  ContactController.php (dossier prestashop/controllers/front)

C'est la partie la plus difficile en effet ;)

Link to comment
Share on other sites

J'ai remplacé le bout de code par le tiens dans la page AdminContactsController.php (dossier prestashop/controllers/admin)  mais je ne vois pas dans BO -> Localisation -> Traductions, le module AdminContacts dans ma liste des modules présents et du coups pas de traduction possible.

Quel version tu utlisies ?

<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

class AdminContactsControllerCore extends AdminController
{
	public function __construct()
	{
	 	$this->table = 'contact';
	 	$this->className = 'Contact';
	 	$this->lang = true;
		$this->addRowAction('edit');
		$this->addRowAction('delete');
	 	$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
		
		/* $this->fields_list = array(
			'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
			'name' => array('title' => $this->l('Title'), 'width' => 130),
			'first_name' => array('title' => $this->l('Title'), 'width' => 130),
			'address' => array('title' => $this->l('Title'), 'width' => 130),
			'city' => array('title' => $this->l('Title'), 'width' => 130),
			'postal_code' => array('title' => $this->l('Title'), 'width' => 130),
			'email' => array('title' => $this->l('Email address'), 'width' => 130),
			'description' => array('title' => $this->l('Description'), 'width' => 150),
		); */

		$this->fields_list = array(
			'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
			'name' => array('title' => $this->l('Name'), 'width' => 130),
			'first_name' => array('title' => $this->l('First name'), 'width' => 130),
			'address' => array('title' => $this->l('Adress'), 'width' => 130),
			'city' => array('title' => $this->l('City'), 'width' => 130),
			'postal_code' => array('title' => $this->l('Postal code'), 'width' => 130),
			'email' => array('title' => $this->l('Email address'), 'width' => 130),
			'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

		parent::__construct();
	}

	public function renderForm()
	{
		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Contacts'),
				'image' => '../img/admin/contact.gif'
			),
			'input' => array(
				array(
					'type' => 'text',
					'label' => $this->l('Title'),
					'name' => 'name',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Contact name (e.g. Customer Support)'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Email address'),
					'name' => 'email',
					'size' => 33,
					'required' => false,
					'desc' => $this->l('Emails will be sent to this address'),
				),
				array(
					'type' => 'radio',
					'label' => $this->l('Save messages?'),
					'name' => 'customer_service',
					'required' => false,
					'class' => 't',
					'is_bool' => true,
					'desc' => $this->l('If enabled, all messages will be saved in the "Customer Service" page under the "Customer" menu.'),
					'values' => array(
						array(
							'id' => 'customer_service_on',
							'value' => 1,
							'label' => $this->l('Enabled')
						),
						array(
							'id' => 'customer_service_off',
							'value' => 0,
							'label' => $this->l('Disabled')
						)
					),
				),
				array(
					'type' => 'textarea',
					'label' => $this->l('Description'),
					'name' => 'description',
					'required' => false,
					'lang' => true,
					'cols' => 36,
					'rows' => 5,
					'desc' => $this->l('Further information regarding this contact'),
				),
			),
			'submit' => array(
				'title' => $this->l('Save   '),
				'class' => 'button'
			)
		);
		
		if (Shop::isFeatureActive())
		{
			$this->fields_form['input'][] = array(
				'type' => 'shop',
				'label' => $this->l('Shop association:'),
				'name' => 'checkBoxShopAsso',
			);
		}

		return parent::renderForm();
	}

}


Ma Class Mail (prestashop\class\Mail.php)

	public static function Send($id_lang, $template, $subject, $template_vars, $to,
		$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
		$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
	{
		$configuration = Configuration::getMultiple(array(
			'PS_SHOP_EMAIL',
			'PS_MAIL_METHOD',
			'PS_MAIL_SERVER',
			'PS_MAIL_USER',
			'PS_MAIL_PASSWD',
			'PS_SHOP_NAME',
			'PS_MAIL_SMTP_ENCRYPTION',
			'PS_MAIL_SMTP_PORT',
			'PS_MAIL_TYPE'
		), null, null, $id_shop);
		
		// Returns immediatly if emails are deactivated
		if ($configuration['PS_MAIL_METHOD'] == 3)
			return true;
		
		$theme_path = _PS_THEME_DIR_;
Link to comment
Share on other sites

Bonjour,

 

Beaucoup de questions ! et des réponses dans mes précédents post

Version PS voir post 4

 

J'ai remplacé le bout de code par le tiens dans la page AdminContactsController.php (dossier prestashop/controllers/admin)  mais je ne vois pas dans BO -> Localisation -> Traductions, le module AdminContacts dans ma liste des modules présents et du coups pas de traduction possible.

Normal, ce n'est pas un module  ;)  mais un controller admin  > voir capture écran Post 9

BO -> Localisation -> Traductions > Traductions Back Office

Pour mon code, je l'ai fait très vite : à vérifier

 

J'aimerai une fois que le formulaire fonctionnera, rajouter un Captcha pour valider le formulaire.

http://catalogo-onlinersi.net/fr/ajouter-ons/264-diapositive-captcha.html

Edited by indesign (see edit history)
Link to comment
Share on other sites

Bon j'ai trouvé grace à toi les traductions de l'admin, je ne connaissais pas ^^ Merci !

J'ai traduit et visiblement cela ne change pas dans les label dur form de contact...

Ils sont toujours en Anglais même si je l'ai est traduit dans l'AdminContacts

Je cherche pourquoi ???

Edited by reaman (see edit history)
Link to comment
Share on other sites

J'ai rajouté dans la fonction renderForm  de la page admin\AdminContactsController.php pour lire les donnéesdu tableau.

$this->fields_list = array(
			'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
			'name' => array('title' => $this->l('Name'), 'width' => 130),
			'first_name' => array('title' => $this->l('First Name'), 'width' => 130),
			'address' => array('title' => $this->l('Address'), 'width' => 130),
			'city' => array('title' => $this->l('City'), 'width' => 130),
			'postal_code' => array('title' => $this->l('Postal Code'), 'width' => 130),
			'email' => array('title' => $this->l('Email address'), 'width' => 130),
			'description' => array('title' => $this->l('Description'), 'width' => 150),
		);

et

public function renderForm()
	{
		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Contacts'),
				'image' => '../img/admin/contact.gif'
			),
			'input' => array(
				array(
					'type' => 'text',
					'label' => $this->l('Name'),
					'name' => 'name',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Contact name (e.g. Customer Support)'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('First Name'),
					'name' => 'first_name',
					'size' => 33,
					'required' => false,
					'lang' => true,
					'desc' => $this->l('First Name'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Address'),
					'name' => 'address',
					'size' => 33,
					'required' => false,
					'lang' => true,
					'desc' => $this->l('Address'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('City'),
					'name' => 'city',
					'size' => 33,
					'required' => false,
					'lang' => true,
					'desc' => $this->l('City'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Postal Code'),
					'name' => 'postal_code',
					'size' => 33,
					'required' => false,
					'lang' => true,
					'desc' => $this->l('Postal Code'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Email address'),
					'name' => 'email',
					'size' => 33,
					'required' => false,
					'lang' => true,
					'desc' => $this->l('Emails will be sent to this address'),
				),
				array(
					'type' => 'radio',
					'label' => $this->l('Save messages?'),
					'name' => 'customer_service',
					'required' => false,
					'class' => 't',
					'is_bool' => true,
					'desc' => $this->l('If enabled, all messages will be saved in the "Customer Service" page under the "Customer" menu.'),
					'values' => array(
						array(
							'id' => 'customer_service_on',
							'value' => 1,
							'label' => $this->l('Enabled')
						),
						array(
							'id' => 'customer_service_off',
							'value' => 0,
							'label' => $this->l('Disabled')
						)
					),
				),
				array(
					'type' => 'textarea',
					'label' => $this->l('Description'),
					'name' => 'description',
					'required' => false,
					'lang' => true,
					'cols' => 36,
					'rows' => 5,
					'desc' => $this->l('Further information regarding this contact'),
				),
			),
			'submit' => array(
				'title' => $this->l('Save   '),
				'class' => 'button'
			)
		);
		
		if (Shop::isFeatureActive())
		{
			$this->fields_form['input'][] = array(
				'type' => 'shop',
				'label' => $this->l('Shop association:'),
				'name' => 'checkBoxShopAsso',
			);
		}

Mais toujours pas de changement de traduction pour les labels :unsure:  

Edited by reaman (see edit history)
Link to comment
Share on other sites

Je suis déjàs en mode dev, je force la compilation à chaque appel et désactive le cache aussi.

Je pense que cela peut venir de ma class Mail car manque les champs que j'ai rajouté dans le form, donc j'ai modifié ainsi :

if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
							$var_list,$contact->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, $from, ($customer->id ? $customer->firstname.' '.$customer->name : ''),
									$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->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, $fileAttachment))
									$this->errors[] = Tools::displayError('An error occurred while sending the message.');
Edited by reaman (see edit history)
Link to comment
Share on other sites

oui effectivement, pas facile la modif dans contactController.php, moi j'ai fait comme ça mais visiblement ça marche pas non plus :(

Je pense que mon problème se situe dans cette page

 

Original :

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.'); 

Modifier :

if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
							$var_list,$contact->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, $from, ($customer->id ? $customer->firstname.' '.$customer->name : ''),
									$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->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, $fileAttachment))
									$this->errors[] = Tools::displayError('An error occurred while sending the message.');
Edited by reaman (see edit history)
Link to comment
Share on other sites

1/ Rajouter les champs personnalisés dans la table ps_customer_thread

2/ CustomerThread.php (dossier prestashop/classes)

class CustomerThreadCore extends ObjectModel
{
	public $id;
	public $id_shop;
	public $id_lang;
	public $id_contact;
	public $id_customer;
	public $id_order;
	public $id_product;
	public $status;
	public $email;
	public $token;
	public $date_add;
	public $date_upd;

	/**
	 * @see ObjectModel::$definition
	 */
	public static $definition = array(
		'table' => 'customer_thread',
		'primary' => 'id_customer_thread',
		'fields' => array(
			'id_lang' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_contact' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_shop' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_customer' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_order' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'email' => 		array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254),
			'token' => 		array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'status' => 	array('type' => self::TYPE_STRING),
			'date_add' => 	array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
			'date_upd' => 	array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
		),
	);

Rajouter les champs personnalisés

public $adress;

 'fields' => array(
            'adress' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

3/ ContactController.php (dossier controllers/front)

Rajouter les champs personnalisés

					$var_list = array(
									'{order_name}' => '-',
									'{attached_file}' => '-',
									'{message}' => Tools::nl2br(stripslashes($message)),
									'{email}' =>  $from,
									'{adress}' =>  (isset($ct) && $ct->adress) ? $ct->adress : ''
								);

4/     ajouter  les champs personnalisés

$ct->adress = Tools::getValue('adress');
avant $ct->update();
$ct->adress = Tools::getValue('adress');
avant $ct->add();
					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();
					}

5/ Rajouter les champs personnalisés dans contact_form.txt contact_form.html (dossier prestashop/mails/fr)

Adress: <strong>{adress}</strong>

 

Edited by indesign (see edit history)
Link to comment
Share on other sites

Bon, je viens d'insérer les champs supplémentaires dans la table customer_thread 

ALTER TABLE  `nmrl_customer_thread`
ADD  `name` CHAR( 50 ) NOT NULL AFTER  `status` , 
ADD  `first_name` CHAR( 50 ) NOT NULL AFTER  `name` ,
ADD  `address` CHAR( 50 ) NOT NULL AFTER  `first_name` ,
ADD  `city` CHAR( 50 ) NOT NULL AFTER  `address` ,
ADD  `postal_code` SMALLINT( 16 ) NOT NULL AFTER  `city` ;

Après j'ai pas trop compris, tu veux que j'atoute dans la page CustomerThread.php le code comme cela :

public $name;

 'fields' => array(
            'name' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName');

public $first_name;

 'fields' => array(
            'first_name' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'); 

public $address;

 'fields' => array(
            'address' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'); 

public $city;

 'fields' => array(
            'city' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'); 

public $postal_code;

 'fields' => array(
            'postal_code' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName');

ou comme cela :

class CustomerThreadCore extends ObjectModel
{
	public $id;
	public $id_shop;
	public $id_lang;
	public $id_contact;
	public $id_customer;
	public $id_order;
	public $id_product;
	public $status;
	public $email;
	public $token;
	public $date_add;
	public $date_upd;

	/**
	 * @see ObjectModel::$definition
	 */
	public static $definition = array(
		'table' => 'customer_thread',
		'primary' => 'id_customer_thread',
		'fields' => array(
			'id_lang' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_contact' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_shop' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_customer' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_order' => 	array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),

			'name' => 		array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
			'first_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
			'address' =>  	array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
			'city' =>  		array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
			'postal_code' =>array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'email' => 		array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254),
			'token' => 		array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'status' => 	array('type' => self::TYPE_STRING),
			'date_add' => 	array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
			'date_upd' => 	array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
		),
	);
	

ContactController.php j'aoute comme ça ?

if (!count($this->errors))
	{
		$var_list = array(
			'{order_name}' => '-',
			'{attached_file}' => '-',
			'{message}' => Tools::nl2br(stripslashes($message)),
			'{email}' =>  $from,
			'{product_name}' => '',
			'{name}' => '',
			'{first_name}' => '',
			'{address}' => '',
			'{city}' => '',
			'{postal_code}' => '',
	);

dans contact_form.txt j'ai ajouté comme cela 

Votre message a bien été envoyé à notre service client.

Votre message :

{message}

Référence commande : {order_name}

Fichier attaché : {attached_file}

Nous vous répondrons dés que possible.

Cordialement,

{shop_url} réalisé avec PrestaShop™

name: <strong>{name}</strong>
frist_name: <strong>first_name</strong>
address: <strong>{address}</strong>
city: <strong>{city}</strong>
postal_code: <strong>{postal_code}</strong>

et dans contact_form.html j'ai ajouté ainsi

<td align="left">
Votre message a bien été envoyé.<br /><br /> 
Vos inforations<br /><br />
Nom : {name}<br /><br />
Prénom : {first_name}<br /><br />
Adresse : {address}<br /><br />
Ville : {city}<br /><br />
Code postale : {postale code }<br /><br /> 
Référence de commande : {order_name} Message : {message}<br /><br /> 
Message : {message} <br /><br /> 
Fichier attaché : {attached_file}</td>

Bon et bien maintenant j'ai une page blanche :(

Edited by reaman (see edit history)
Link to comment
Share on other sites

Bon now cela fonctionne avec la traduction  :)

 

Maintenant j'aimerai que tout les champs soit obligatoires et mettre la phrase * Champs obligatoires dans lesdifférentes langues du site et ajouter le captcha pour la validation et là il sera complet ;)

Edited by reaman (see edit history)
Link to comment
Share on other sites

Bonsoir reaman,

 

Un petit "Like This" pour tout le temps passé. ;)

 

La cerise sur le gâteau un Captcha

Captcha > voir Post 12  (à tester)

 

tous les champs soit obligatoirement à remplir.

'required' => true

 

Si le problème est réglé, mettre le post en [Résolu]  

Ça ferra plaisir aux modérateurs, et aux bénévoles qui lisent le(s) post(s).


 

Procédure à suivre :
 Edit le premier post > Use Full Editor et rajouter devant le titre [Résolu]

Edited by indesign (see edit history)
  • Like 1
Link to comment
Share on other sites

Pour le Captcha je vais utliser celui là 

Pour la phrase * Champs obligatoires je vais voir pour quelle soit aussi en multi langues

 

Que te dire d'autre qu'un grand merci Indesign pour ton aide, ta patience !!!

Grace à toi j'ai appris beaucoup de chose et grand respet Maitre Jedi !!!

Que la force soit avec toi ;)

 

Je vois ça demain et si tout roule je mettrai [Résolu] sinon je viendrai t'embêter une dernière fois  ^^

Edited by reaman (see edit history)
Link to comment
Share on other sites

J'ai 2 problèmes qui sont les champs obligatoire et l'envoi qui enmène sur une page blanche et pas sur la page de confirmation d'envoi.

 

Pour les champs obligatoires, j'ai rajouter 'required' => true dans les pages suivantes, mais visiblement cela ne fonctionne pas car quand je teste, seul les champ e-mail et message obtiens un message d'alerte !

 

CustomerThread.php (dossier prestashop/classes)

/**
	 * @see ObjectModel::$definition
	 */
	public static $definition = array(
		'table' => 'customer_thread',
		'primary' => 'id_customer_thread',
		'fields' => array(
			'id_lang' => 	 array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_contact' =>  array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
			'id_shop' => 	 array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_order' => 	 array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_product' =>  array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
	/* Champ pour le formulaire, pour rendre un champ obligatore, on rajoute ,'required' => true), */
			'name' => 		 array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'first_name' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'address' =>  	 array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'city' =>  		 array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'postal_code' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),

			'email' => 		 array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254, 'required' => true),
			'token' => 		 array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
			'status' => 	 array('type' => self::TYPE_STRING),
			'date_add' => 	 array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
			'date_upd' => 	 array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
		),
	);

AdminContactsController.php (dossier prestashop/controllers/admin)

public function renderForm()
	{
		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Contacts'),
				'image' => '../img/admin/contact.gif'
			),
			'input' => array(
				array(
					'type' => 'text',
					'label' => $this->l('Name'),
					'name' => 'name',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Contact name (e.g. Customer Support)'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('First Name'),
					'name' => 'first_name',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('First Name'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Address'),
					'name' => 'address',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Address'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('City'),
					'name' => 'city',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('City'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Postal Code'),
					'name' => 'postal_code',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Postal Code'),
				),
				array(
					'type' => 'text',
					'label' => $this->l('Email address'),
					'name' => 'email',
					'size' => 33,
					'required' => true,
					'lang' => true,
					'desc' => $this->l('Emails will be sent to this address'),
				),
				array(
					'type' => 'radio',
					'label' => $this->l('Save messages?'),
					'name' => 'customer_service',
					'required' => false,
					'class' => 't',
					'is_bool' => true,
					'desc' => $this->l('If enabled, all messages will be saved in the "Customer Service" page under the "Customer" menu.'),
					'values' => array(
						array(
							'id' => 'customer_service_on',
							'value' => 1,
							'label' => $this->l('Enabled')
						),
						array(
							'id' => 'customer_service_off',
							'value' => 0,
							'label' => $this->l('Disabled')
						)
					),
				),
				array(
					'type' => 'textarea',
					'label' => $this->l('Description'),
					'name' => 'description',
					'required' => true,
					'lang' => true,
					'cols' => 36,
					'rows' => 5,
					'desc' => $this->l('Further information regarding this contact'),
				),
			),
			'submit' => array(
				'title' => $this->l('Save   '),
				'class' => 'button'
			)
		);
		
		if (Shop::isFeatureActive())
		{
			$this->fields_form['input'][] = array(
				'type' => 'shop',
				'label' => $this->l('Shop association:'),
				'name' => 'checkBoxShopAsso',
			);
		}

		return parent::renderForm();
	}

}

Edited by reaman (see edit history)
Link to comment
Share on other sites

Pour le Captcha je vais utliser celui là 

Pas sûr :huh:  qu'il fonctionne avec les dernières versions de PS...

 

Page blanche liée à ton problème initial du post. > Actives les erreurs defines.inc.php

Donc je ne comprends pas pourquoi depuis le formulaire de contact d'origine cela ne fonctionne pas !?

 

Pour les champs obligatoires, dans le fichier ContactController.php  (Front)

Edited by indesign (see edit history)
Link to comment
Share on other sites

Bon voici les message d'erreur que j'ai d'abort dans le formulaire puis dans l'envoi de celui ci

 

Formulaire :

 

mini_131014122225352347.jpg

 

Envoi du formulaire :

 

mini_131014122343475280.jpg

 

Pour la traduction de la phrase * Champ requis dois-je créer un champ dans la table Customer thread ?

 

Champ obligatoire ne fonctionne pas même avec required => true

 

Fichier ContactController.php (controllers/front)

<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

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.
			if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from))
				$this->errors[] = Tools::displayError('Invalid email address.');
			else if (!$message)
				$this->errors[] = Tools::displayError('The message cannot be blank.');
			else if (!Validate::isCleanHtml($message))
				$this->errors[] = Tools::displayError('Invalid message');
			else if (!($id_contact = (int)(Tools::getValue('id_contact'))) || !(Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))))
				$this->errors[] = Tools::displayError('Please select a subject from the list provided. ');
			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->name = Tools::getValue('name');
						$ct->first_name = Tools::getValue('first_name');
						$ct->address = Tools::getValue('address');
						$ct->city = Tools::getValue('city');
						$ct->postal_code = Tools::getValue('postal_code');
						$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->token = Tools::passwdGen(12);
						$ct->name = Tools::getValue('name');
						$ct->first_name = Tools::getValue('first_name');
						$ct->address = Tools::getValue('address');
						$ct->city = Tools::getValue('city');
						$ct->postal_code = Tools::getValue('postal_code');
						$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($_SERVER['REMOTE_ADDR']);
						$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}' => '',
									'{name}' => '', // ajout des champs
									'{first_name}' => '',
									'{address}' => '',
									'{city}' => '',
									'{postal_code}' => '',
								);

					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
					{											
						/* 
						Original
						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 (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
			
							$var_list,$contact->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, 
								$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->name, $contact->first_name, $contact->address, $contact->city, $contact->postal_code, $contact->email, $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');
	}

	/**
	 * 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);
		}
	}
}
Edited by reaman (see edit history)
Link to comment
Share on other sites

Je ne comprends pas pourquoi ils ne sont pas reconnu  :blink:  :wub:

Bon on prends le 1er champs Nom

 

Message d'erreur nous dis :

 

Notice: Undefined index: name in D:\wamp\www\mon_site\cache\smarty\compile\fa\24\c2\fa24c25c1cd81fe76b276e9ac7196a72d929aa53.file.contact-form.tpl.php on line 144

 

Donc champ pas reconnu (undefined index) ligne 144, regardons cette ligne du fichier contact-form.tpl :

{if isset($isLogged) && $isLogged}
			<p class="text select">
			<label for="id_product">{l s='Product'}<span class="ob">*</span></label>
				{if !isset($customerThread.id_product)}
				{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}
				{elseif $customerThread.id_product > 0}
					<input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
				{/if} 

la ligne 144 est le <slelect name="id_product"... C'est le champ Objet et il fonctionne bien alors, je ne vois pas le problème vue que je n'y est pas touché en plus ... et pourquoi ne sont-il pas reconnu ???? script complet de la page en dessous

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

{capture name=path}{l s='Contact'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}

<h1><span>{l s='Customer service'} - {if isset($customerThread) && $customerThread}{l s='Your reply'}{else}{l s='Contact us'}{/if}</span></h1>
{if isset($confirmation)}
	<p class="success"><i class="icon-ok"></i>{l s='Your message has been successfully sent to our team.'}</p>
	<ul class="footer_links">
		<li><a href="{$base_dir}"><i class="icon-home"></i>{l s='Home'}</a></li>
	</ul>
{elseif isset($alreadySent)}
	<p>{l s='Your message has already been sent.'}</p>
	<ul class="footer_links">
		<li><a href="{$base_dir}"><i class="icon-home"></i>{l s='Home'}</a></li>
	</ul>
{else}
	<p class="title-pagecontact"><i class="icon-comment-alt"></i>{l s='For questions about an order or for more information about our products'}.</p>
	{include file="$tpl_dir./errors.tpl"}
	<form id="contact_form" action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data">
		<fieldset class="titled_box">
			<h2><span>{l s='send a message'}</span></h2>
			<p class="select">
				<label for="id_contact">{l s='Subject Heading'}<span class="ob">*</span></label>
			{if isset($customerThread.id_contact)}
				{foreach from=$contacts item=contact}
					{if $contact.id_contact == $customerThread.id_contact}
						<input type="text" id="contact_name" name="contact_name" value="{$contact.name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
						<input type="hidden" name="id_contact" value="{$contact.id_contact}" />
					{/if}
				{/foreach}
			</p>
			{else}
				<select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
					<option value="0">{l s='-- Choose --'}</option>
				{foreach from=$contacts item=contact}
					<option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
				{/foreach}
				</select>
			</p>
			<p id="desc_contact0" class="desc_contact"> </p>
				{foreach from=$contacts item=contact}
					<p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">
						{$contact.description|escape:'htmlall':'UTF-8'}
					</p>
				{/foreach}
			{/if}
			<!-- ajout champ -->
			<p class="text 0">
			    <label for="name">{l s='Name'}<span class="ob">*</span></label>
			    {if isset($customerThread.name)}
			        <input type="text 1" id="name" name="name" value="{$customerThread.name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
			    {else}
			        <input type="text" id="name" name="name" value="{$name|escape:'htmlall':'UTF-8'}" />
			   	{/if}
			</p>
			<p class="text">
			    <label for="first_name">{l s='First Name'}<span class="ob">*</span></label>
			    {if isset($customerThread.first_name)}
			        <input type="text" id="first_name" name="first_name" value="{$customerThread.first_name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
			    {else}
			        <input type="text" id="first_name" name="first_name" value="{$first_name|escape:'htmlall':'UTF-8'}" />
			    {/if}
			</p>
			<p class="text">
			    <label for="address">{l s='Address'}<span class="ob">*</span></label>
			    {if isset($customerThread.address)}
			        <input type="text" id="address" name="address" value="{$customerThread.address|escape:'htmlall':'UTF-8'}" readonly="readonly" />
			    {else}
			        <input type="text" id="address" name="address" value="{$address|escape:'htmlall':'UTF-8'}" />
			    {/if}
			</p>
			<p class="text">
			    <label for="city">{l s='City'}<span class="ob">*</span></label>
			    {if isset($customerThread.city)}
			        <input type="text" id="city" name="city" value="{$customerThread.city|escape:'htmlall':'UTF-8'}" readonly="readonly" />
			    {else}
			        <input type="text" id="city" name="city" value="{$city|escape:'htmlall':'UTF-8'}" />
			    {/if}
			</p>
			<p class="text">
			    <label for="postal_code">{l s='Postal Code'}<span class="ob">*</span></label>
			    {if isset($customerThread.postal_code)}
			        <input type="text" id="postal_code" name="postal_code" value="{$customerThread.postal_code|escape:'htmlall':'UTF-8'}" readonly="readonly" />
			    {else}
			        <input type="text" id="postal_code" name="postal_code" value="{$postal_code|escape:'htmlall':'UTF-8'}" />
			    {/if}
			</p>
			<!-- Fin ajout de champ -->
			<p class="text">
				<label for="email">{l s='Email address'}<span class="ob">*</span></label>
				{if isset($customerThread.email)}
					<input type="email" id="email" name="from" value="{$customerThread.email|escape:'htmlall':'UTF-8'}" readonly="readonly" />
				{else}
					<input type="email" id="email" name="from" value="{$email|escape:'htmlall':'UTF-8'}" />
				{/if}
			</p>
		{if !$PS_CATALOG_MODE}
			{if (!isset($customerThread.id_order) || $customerThread.id_order > 0)}
			<p class="text select">
				<label for="id_order">{l s='Order Reference'}<span class="ob">*</span></label>
				{if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1}
					<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>
				{elseif !isset($customerThread.id_order) && !isset($isLogged)}
					<input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" />
				{elseif $customerThread.id_order > 0}
					<input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly="readonly" />
				{/if}
			</p>
			{/if}
			{if isset($isLogged) && $isLogged}
			<p class="text select">
			<label for="id_product">{l s='Product'}<span class="ob">*</span></label>
				{if !isset($customerThread.id_product)}
				{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}
				{elseif $customerThread.id_product > 0}
					<input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
				{/if}
			</p>
			{/if}
		{/if}
		{if $fileupload == 1}
			<p class="text upload-file">
			<label for="fileUpload">{l s='Attach File'}<span class="ob">*</span></label>
				<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
				<input  type="file" name="fileUpload" id="fileUpload" />
			</p>
		{/if}
		<p class="textarea">
			<label for="message">{l s='Message'}<span class="ob">*</span></label>
			 <textarea id="message" name="message" rows="15" cols="10">{if isset($message)}{$message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>
		</p>
		<p class="title-pagecontact mgh"><i class="icon-comment-alt"></i><span class="ob">*</span>{l s='Required Field'}.</p>
		<p class="submit">
			<input  class="button" type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}"  onclick="$(this).fadeOut('slow');" />
		</p>
	</fieldset>
</form>
{/if}

Edited by reaman (see edit history)
Link to comment
Share on other sites

Bonjour reaman,

 

Je n'ai pas modifié les fichiers, ni la BD... donc je ne peux pas tester et trouver la raison du problème. ;)

 

 

Peux tu m'aider ?

Désolé, mais j'ai aussi quelques obligations... Je pense avoir largement contribué jusque-là, non ?

 

 

Si tu tiens, tellement à ce dev spécifique, tu peux aussi "louer" les services d'un prestataire spécialiste de PS, en postant dans le forum appels d'offres et prestations et en faisant référence à ce post.

Il trouvera, surement et rapidement, la solution et tu pourras consacré ton énergie sur d'autres améliorations ou autres problèmes.

 

Cordialement,

Edited by indesign (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...