Jump to content

nicolange

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • First Name
    Nico
  • Last Name
    Cou

nicolange's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. it seems that the field id_shop cannot be modifyed. I simply created a new field and it's good now.
  2. Hello, I have a problem in customizing my identity page. I would like to add an id_shop field , so I manage to create a select field with all shops existing on the site, but there is a problem when submitting the form. I am redirected to the home page (even if required fields are empties). Here is the identity.tpl file (in the theme dir) : {* * 2007-2015 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-2015 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} <a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}"> {l s='My account'} </a> <span class="navigation-pipe"> {$navigationPipe} </span> <span class="navigation_page"> {l s='Your personal information'} </span> {/capture} <div class="box"> <h1 class="page-subheading"> {l s='Your personal information'} </h1> {include file="$tpl_dir./errors.tpl"} {if isset($confirmation) && $confirmation} <p class="alert alert-success"> {l s='Your personal information has been successfully updated.'} {if isset($pwd_changed)}<br />{l s='Your password has been sent to your email:'} {$email}{/if} </p> {else} <p class="info-title"> {l s='Please be sure to update your personal information if it has changed.'} </p> <p class="required"> <sup>*</sup>{l s='Required field'} </p> <form action="{$link->getPageLink('identity', true)|escape:'html':'UTF-8'}" method="post" class="std"> <fieldset> <!-- <div class="clearfix"> <label>{l s='Social title'}</label> <br /> {foreach from=$genders key=k item=gender} <div class="radio-inline"> <label for="id_gender{$gender->id}" class="top"> <input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id|intval}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} /> {$gender->name}</label> </div> {/foreach} </div> --> <div class="required form-group"> <label class="required"> Boulangerie de référence</label> <select id="id_shop" name="id_shop" class="is_required validate form-control"> <option value="">--</option> {section name=boutiques loop=$reqStores} <option {if isset($smarty.post.id_shop) && ($smarty.post.id_shop==$reqStores[boutiques]["id_store"])}selected='selected'{/if} value='{$reqStores[boutiques]["id_store"]}'>{$reqStores[boutiques]["city"]} - {$reqStores[boutiques]["postcode"]}</option> {/section} </select> </div> <div class="required form-group"> <label for="firstname" class="required"> {l s='First name'} </label> <input class="is_required validate form-control" data-validate="isName" type="text" id="firstname" name="firstname" value="{$smarty.post.firstname}" /> </div> <div class="required form-group"> <label for="lastname" class="required"> {l s='Last name'} </label> <input class="is_required validate form-control" data-validate="isName" type="text" name="lastname" id="lastname" value="{$smarty.post.lastname}" /> </div> <div class="required form-group"> <label for="email" class="required"> {l s='E-mail address'} </label> <input class="is_required validate form-control" data-validate="isEmail" type="email" name="email" id="email" value="{$smarty.post.email}" /> </div> <div class="required form-group"> <label for="old_passwd" class="required"> {l s='Current Password'} </label> <input class="is_required validate form-control" type="password" data-validate="isPasswd" name="old_passwd" id="old_passwd" /> </div> <div class="password form-group"> <label for="passwd"> {l s='New Password'} </label> <input class="is_required validate form-control" type="password" data-validate="isPasswd" name="passwd" id="passwd" /> </div> <div class="password form-group"> <label for="confirmation"> {l s='Confirmation'} </label> <input class="is_required validate form-control" type="password" data-validate="isPasswd" name="confirmation" id="confirmation" /> </div> {if isset($newsletter) && $newsletter} <div class="checkbox"> <label for="newsletter"> <input type="checkbox" id="newsletter" name="newsletter" value="1" {if isset($smarty.post.newsletter) && $smarty.post.newsletter == 1} checked="checked"{/if}/> {l s='Sign up for our newsletter!'} {if array_key_exists('newsletter', $field_required)} <sup> *</sup> {/if} </label> </div> {/if} {if isset($optin) && $optin} <div class="checkbox"> <label for="optin"> <input type="checkbox" name="optin" id="optin" value="1" {if isset($smarty.post.optin) && $smarty.post.optin == 1} checked="checked"{/if}/> {l s='Receive special offers from our partners!'} {if array_key_exists('optin', $field_required)} <sup> *</sup> {/if} </label> </div> {/if} {if $b2b_enable} <h1 class="page-subheading"> {l s='Your company information'} </h1> <div class="form-group"> <label for="">{l s='Company'}</label> <input type="text" class="form-control" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" /> </div> <div class="form-group"> <label for="siret">{l s='SIRET'}</label> <input type="text" class="form-control" id="siret" name="siret" value="{if isset($smarty.post.siret)}{$smarty.post.siret}{/if}" /> </div> <div class="form-group"> <label for="ape">{l s='APE'}</label> <input type="text" class="form-control" id="ape" name="ape" value="{if isset($smarty.post.ape)}{$smarty.post.ape}{/if}" /> </div> <div class="form-group"> <label for="website">{l s='Website'}</label> <input type="text" class="form-control" id="website" name="website" value="{if isset($smarty.post.website)}{$smarty.post.website}{/if}" /> </div> {/if} {$HOOK_CUSTOMER_IDENTITY_FORM} <div class="form-group"> <button type="submit" name="submitIdentity" class="btn btn-default button button-medium"> <span>{l s='Save'}<i class="icon-chevron-right right"></i></span> </button> </div> </fieldset> </form> <!-- .std --> {/if} </div> <ul class="footer_links clearfix"> <li> <a class="btn btn-default button button-small" href="{$link->getPageLink('my-account', true)}"> <span> <i class="icon-chevron-left"></i>{l s='Back to your account'} </span> </a> </li> <li> <a class="btn btn-default button button-small" href="{$base_dir}"> <span> <i class="icon-chevron-left"></i>{l s='Home'} </span> </a> </li> <li> <a class="btn btn-default button button-small" href="{$link->getPageLink('history', true)|escape:'html':'UTF-8'}" title="{l s='Historique'}"> <span> {l s='Historique'} </span> </a> </li> </ul> And the IdentityController.php file in override/controllers/front/ dir : <?php class IdentityController extends IdentityControllerCore { public function postProcess() { $origin_newsletter = (bool)$this->customer->newsletter; if (Tools::isSubmit('submitIdentity')) { $email = trim(Tools::getValue('email')); if (Tools::getIsset('old_passwd')) $old_passwd = trim(Tools::getValue('old_passwd')); if (!Validate::isEmail($email)) $this->errors[] = Tools::displayError('This email address is not valid'); elseif ($this->customer->email != $email && Customer::customerExists($email, true)) $this->errors[] = Tools::displayError('An account using this email address has already been registered.'); elseif (!Tools::getIsset('old_passwd') || (Tools::encrypt($old_passwd) != $this->context->cookie->passwd)) $this->errors[] = Tools::displayError('The password you entered is incorrect.'); elseif (Tools::getValue('passwd') != Tools::getValue('confirmation')) $this->errors[] = Tools::displayError('The password and confirmation do not match.'); elseif( !Tools::getIsset('id_shop') || Tools::getValue('id_shop') == '' ) $this->errors[] = "Une boulangerie de référence doit être définie."; else { $prev_id_default_group = $this->customer->id_default_group; // Merge all errors of this file and of the Object Model $this->errors = array_merge($this->errors, $this->customer->validateController()); } if (!count($this->errors)) { $this->customer->id_default_group = (int)$prev_id_default_group; $this->customer->firstname = Tools::ucwords($this->customer->firstname); $this->customer->id_shop = Tools::getValue('id_shop') ; if (Configuration::get('PS_B2B_ENABLE')) { $this->customer->website = Tools::getValue('website'); // force update of website, even if box is empty, this allows user to remove the website $this->customer->company = Tools::getValue('company'); } if (!Tools::getIsset('newsletter')) $this->customer->newsletter = 0; elseif (!$origin_newsletter && Tools::getIsset('newsletter')) if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) if ($module_newsletter->active) $module_newsletter->confirmSubscription($this->customer->email); if (!Tools::getIsset('optin')) $this->customer->optin = 0; if (Tools::getValue('passwd')) $this->context->cookie->passwd = $this->customer->passwd; if ($this->customer->update()) { $this->context->cookie->customer_lastname = $this->customer->lastname; $this->context->cookie->customer_firstname = $this->customer->firstname; $this->context->smarty->assign('confirmation', 1); } else $this->errors[] = Tools::displayError('The information cannot be updated.'); } } else $_POST = array_map('stripslashes', $this->customer->getFields()); return $this->customer; } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if ($this->customer->birthday) $birthday = explode('-', $this->customer->birthday); else $birthday = array('-', '-', '-'); $reqStores = Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'store WHERE active="1"'); /* Generate years, months and days */ $this->context->smarty->assign(array( 'years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders(), 'idshop' =>Tools::getValue('id_shop') )); // Call a hook to display more information $this->context->smarty->assign(array( 'HOOK_CUSTOMER_IDENTITY_FORM' => Hook::exec('displayCustomerIdentityForm'), 'reqStores' => $reqStores )); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); $this->setTemplate(_PS_THEME_DIR_.'identity.tpl'); } } Thanls a lot.
×
×
  • Create New...