abacosrl Posted February 20, 2014 Share Posted February 20, 2014 (edited) Salve, io sto cercando di aggiungere dei campi alla form di contatto.Ho seguito questo articolo: http://nemops.com/adding-new-fields-to-prestashop-contact-form/ La form è cambiata ma i dati non vengono salvati nel Datbase e non vengono inviati via email. IO vorrei inserire i seguenti campi: society, phone, address, city.Scrivo di seguito le modiifche che ho apportato:Nel File conctact-form.tpl <p class="text"> <label for="society">{l s='Nome / Ragione Sociale'}</label> <input type="text" id="society" name="society" value="{if isset($smarty.post.society)}{$smarty.post.society|escape:'htmlall'|stripslashes}{/if}"/> </p> <p class="text"> <label for="phone">{l s='Telefono'}</label> <input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone|escape:'htmlall'|stripslashes}{/if}" /> </p> <p class="text"> <label for="address">{l s='Indirizzo'}</label> <input type="text" id="address" name="address" value="{if isset($smarty.post.address)}{$smarty.post.address|escape:'htmlall'|stripslashes}{/if}" /> <label for="city">{l s='Città'}</label> <input type="text" id="city" name="city" value="{if isset($smarty.post.city)}{$smarty.post.city|escape:'htmlall'|stripslashes}{/if}" /> </p> ho creato il file: override/classes/CustomerThread.php <?php class CustomerThread extends CustomerThreadCore { public $society; public $phone; public $address; public $city; 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'), 'society' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'address' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'city' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName') ), ); } ho modiifcato nel file: override/controllers/front/ContactConroller.php if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) $this->errors[] = Tools::displayError('Invalid email address.'); elseif (!($society = nl2br2(Tools::getValue('society')))) $this->errors[] = Tools::displayError('The name cannot be blank.'); elseif (!($phone = nl2br2(Tools::getValue('phone')))) $this->errors[] = Tools::displayError('The phone cannot be blank.'); elseif (!($address = nl2br2(Tools::getValue('address')))) $this->errors[] = Tools::displayError('The address cannot be blank.'); elseif (!($city = nl2br2(Tools::getValue('city')))) $this->errors[] = Tools::displayError('The city cannot be blank.'); else if (!$message) $this->errors[] = Tools::displayError('The message cannot be blank.'); 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->society = Tools::getValue('society'); $ct->phone = Tools::getValue('phone'); $ct->address = Tools::getValue('address'); $ct->city = Tools::getValue('city'); $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->society = Tools::getValue('society'); $ct->phone = Tools::getValue('phone'); $ct->address = Tools::getValue('address'); $ct->city = Tools::getValue('city'); $ct->add(); } if (!count($this->errors)) { $var_list = array( '{order_name}' => '-', '{attached_file}' => '-', '{message}' => Tools::nl2br(stripslashes($message)), '{email}' => $from, '{product_name}' => '', '{society}' => (isset($ct) && $ct->society) ? $ct->society : '', '{phone}' => (isset($ct) && $ct->phone) ? $ct->phone : '', '{address}' => (isset($ct) && $ct->address) ? $ct->address : '', '{city}' => (isset($ct) && $ct->city) ? $ct->city : '' ); Ho aggiunto le righe nella tabella come da immagine allegata e inserito nelle mail i campi... Qualcuno saprebbe aiutarmi per poter alemno inviare i dati inseriti nella form via email? Attualmente nell'email dove dovrebbe essere passati i valori mi rimangono così:Nome / Ragione Sociale: {society}Grazie mille Edited February 20, 2014 by abacosrl (see edit history) 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