Jump to content

Edit History

gouna

gouna

Bonjour,

Sur ma version de prestashop 1.7.8.11, si un client veut ajouter ou modifier son numéro de téléphone, il faut qu'il se rende dans "Adresses" puis sélectionne son adresse afin d'accéder à une page qui lui permette de modifier son numéro de téléphone. Je ne trouve pas çà très logique.

Est-il possible d'ajouter le champs de téléphonie quand on se rend dans "Mon Compte", puis dans "Informations" ? On peut modifier son mail ici donc je trouve logique qu'on puisse également modifier son numéro de téléphone, tout simplement.
Sanstitre.thumb.png.83c2115d6e73f191ad386a358ad74d9e.png

Mon fichier templates/customer/_partiel/customer-form.tpl :

{block name='customer_form'}

  {block name='customer_form_errors'}
    {include file='_partials/form-errors.tpl' errors=$errors['']}
  {/block}

  <form class="js-customer-form needs-validation" id="customer-form" action="{block name='customer_form_actionurl'}{$action}{/block}" method="post" novalidate autocomplete="false">
    {block name='customer_form_fields'}
      <section class="form-fields">
        {block name='form_fields'}
          {foreach from=$formFields item="field"}
            {block name='form_field'}
              {form_field field=$field}
            {/block}
          {/foreach}
          {$hook_create_account_form nofilter}
        {/block}
      </section>
    {/block}

    {block name='customer_form_footer'}
      <footer class="form-footer">
        <input type="hidden" name="submitCreate" value="1">
        {block name='form_buttons'}
          <button class="btn btn-primary form-control-submit" type="submit" data-link-action="save-customer">
            {l s='Save' d='Shop.Theme.Actions'}
          </button>
        {/block}
      </footer>
    {/block}
  </form>

{/block}


Mon fichier templates/customer/_partial/address-form.tpl :

{block name='address_form'}
  <div class="js-address-form">

    {block name='address_form_errors'}
      {include file='_partials/form-errors.tpl' errors=$errors['']}
    {/block}

    {block name='address_form_url'}
    <form
      method="POST"
      class="needs-validation"
      action="{url entity='address' params=['id_address' => $id_address]}"
      data-id-address="{$id_address}"
      data-refresh-url="{url entity='address' params=['ajax' => 1, 'action' => 'addressForm']}"
      novalidate
      autocomplete="false"
    >
    {/block}

      {block name='address_form_fields'}
        <section class="form-fields">
          {block name='form_fields'}
            {foreach from=$formFields item="field"}
              {block name='form_field'}
                {form_field field=$field}
              {/block}
            {/foreach}
          {/block}
        </section>
      {/block}

      {block name='address_form_footer'}
        <footer class="form-footer">
          <input type="hidden" name="submitAddress" value="1">
          {block name='form_buttons'}
            <button class="btn btn-primary form-control-submit" type="submit">
              {l s='Save' d='Shop.Theme.Actions'}
            </button>
          {/block}
        </footer>
      {/block}
    </form>
    
  </div>
{/block}


Fichier template/_partial/form-fields.tpl :

{**
 * 2007-2017 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (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:
 * https://opensource.org/licenses/AFL-3.0
 * 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 <contact@prestashop.com>
 * @copyright 2007-2017 PrestaShop SA
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *}
{$autocomplete =
['firstname' => 'given-name',
'lastname' => 'family-name',
'email'=>'email',
'password'=>'current-password',
'new_password'=>'new-password',
'postcode'=>'postal-code',
'birthday'=>'bday',
'address1'=>'street-address',
'address2'=>'address-line2',
'id_state'=>'address-level1',
'city'=>'address-level2',
'company'=>'organization'
]}
{if $field.type == 'hidden'}

    {block name='form_field_item_hidden'}
        <input type="hidden" name="{$field.name}" value="{$field.value}">
    {/block}

{else}
    {assign var=uniqId value=10|mt_rand:100000}

    <div class="form-group">
        {if $field.type == 'checkbox' || $field.type == 'radio-buttons'}
            {if $field.type == 'radio-buttons'}
                <div class="label mr-3">{$field.label}</div>
            {/if}
        {else}
            <label class="{if $field.required}required{/if}" for="f-{$field.name}_{$uniqId}">
                {$field.label}
                {block name='form_field_comment'}
                    {if (!$field.required && !in_array($field.type, ['radio-buttons', 'checkbox']))}
                            <small class="text-muted">({l s='Optional' d='Shop.Forms.Labels'})</small>
                    {/if}
                {/block}
            </label>
        {/if}


            {if $field.type === 'select'}

                {block name='form_field_item_select'}
                    <select class="custom-select{if !empty($field.errors)} is-invalid{/if}" name="{$field.name}" id="f-{$field.name}_{$uniqId}"{if $field.required} required{/if}>
                        <option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
                        {foreach from=$field.availableValues item="label" key="value"}
                            <option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
                        {/foreach}
                    </select>
                {/block}

            {elseif $field.type === 'countrySelect'}

                {block name='form_field_item_country'}
                    <select
                            class="custom-select js-country{if !empty($field.errors)} is-invalid{/if}"
                            name="{$field.name}"
                            id="f-{$field.name}_{$uniqId}"
                            {if $field.required}required{/if}
                    >
                        <option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
                        {foreach from=$field.availableValues item="label" key="value"}
                            <option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
                        {/foreach}
                    </select>
                {/block}

            {elseif $field.type === 'radio-buttons'}

                {block name='form_field_item_radio'}
                    {foreach from=$field.availableValues item="label" key="value" name="radiolist"}
                        <div class="custom-control custom-radio custom-control-inline">
                            <input
                                    name="{$field.name}"
                                    type="radio"
                                    value="{$value}"
                                    class="custom-control-input {if !empty($field.errors)} is-invalid{/if}"
                                    id="f-{$field.name}_{$uniqId}-{$smarty.foreach.radiolist.iteration}"
                                    {if $field.required}required{/if}
                                    {if $value eq $field.value} checked {/if}
                            >

                            <label class="custom-control-label" for="f-{$field.name}_{$uniqId}-{$smarty.foreach.radiolist.iteration}">{$label}</label>
                        </div>
                    {/foreach}

                {/block}

            {elseif $field.type === 'checkbox'}

                {block name='form_field_item_checkbox'}
                    <div class="custom-control custom-checkbox">
                        <input name="{$field.name}" type="checkbox" value="1" id="f-{$field.name}_{$uniqId}" class="custom-control-input{if !empty($field.errors)} is-invalid{/if}"{if $field.value} checked="checked"{/if}{if $field.required} required{/if}>
                        <label class="custom-control-label" for="f-{$field.name}_{$uniqId}">{$field.label nofilter}</label>
                    </div>
                {/block}

            {elseif $field.type === 'date'}

                {block name='form_field_item_date'}
                    <input name="{$field.name}" class="form-control{if !empty($field.errors)} is-invalid{/if}" type="date" value="{$field.value}" placeholder="{if isset($field.availableValues.placeholder)}{$field.availableValues.placeholder}{/if}" id="f-{$field.name}_{$uniqId}"{if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}>
                    {if isset($field.availableValues.comment)}
                        <span class="form-text text-muted">
              {$field.availableValues.comment}
            </span>
                    {/if}
                {/block}

            {elseif $field.type === 'birthday'}

                {block name='form_field_item_birthday'}
                    <div class="js-parent-focus">
                        {html_select_date
                        field_order=DMY
                        time={$field.value}
                        field_array={$field.name}
                        prefix=false
                        reverse_years=true
                        field_separator='<br>'
                        day_extra='class="form-control form-control-select"'
                        month_extra='class="form-control form-control-select"'
                        year_extra='class="form-control form-control-select"'
                        day_empty={l s='-- day --' d='Shop.Forms.Labels'}
                        month_empty={l s='-- month --' d='Shop.Forms.Labels'}
                        year_empty={l s='-- year --' d='Shop.Forms.Labels'}
                        start_year={'Y'|date}-100 end_year={'Y'|date}
                        }
                    </div>
                {/block}

            {elseif $field.type === 'password'}

                {block name='form_field_item_password'}
                    <div class="input-group js-parent-focus">
                        <input
                                class="form-control js-child-focus js-visible-password{if !empty($field.errors)} is-invalid{/if}"
                                name="{$field.name}"
                                id="f-{$field.name}_{$uniqId}"
                                type="password"
                                value=""
                                pattern=".{literal}{{/literal}5,{literal}}{/literal}"
                                {if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}
                                {if $field.required}required{/if}
                        >
                        <span class="input-group-btn">
              <button
                      class="btn btn-light"
                      type="button"
                      data-action="show-password"
                      data-text-show="{l s='Show' d='Shop.Theme.Actions'}"
                      data-text-hide="{l s='Hide' d='Shop.Theme.Actions'}"
              >
                {l s='Show' d='Shop.Theme.Actions'}
              </button>
            </span>
                        {include file='_partials/form-errors.tpl' errors=$field.errors required=$field.required label=$field.label}

                    </div>
                    <small class="form-text text-muted">{l s='At least 5 characters long' d='Shop.Forms.Help'}</small>

                {/block}

            {elseif $field.type === 'file'}
                <div class="custom-file">
                    <input name="{$field.name}" type="file" class="custom-file-input{if !empty($field.errors)} is-invalid{/if}" id="f-{$field.name}_{$uniqId}"{if $field.required} required{/if}>
                    <label class="custom-file-label" for="f-{$field.name}_{$uniqId}" data-browse="{l s='Choose file' d='Shop.Theme.Actions'}">{l s='Choose file' d='Shop.Theme.Actions'}</label>
                </div>
            {else}

                {block name='form_field_item_other'}
                    <input
                            class="form-control{if !empty($field.errors)} is-invalid{/if}"
                            name="{$field.name}"
                            type="{if $field.name === "phone" || $field.name === "phone_mobile"}tel{else}{$field.type}{/if}"
                            value="{$field.value}"
                            id="f-{$field.name}_{$uniqId}"
                            {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if}
                            {if $field.maxLength}maxlength="{$field.maxLength}"{/if}
                            {if $field.required}required{/if}
                            {if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}
                    >
                    {if isset($field.availableValues.comment)}
                        <small class="form-text text-muted">
                            {$field.availableValues.comment}
                        </small>
                    {/if}
                {/block}

            {/if}

            {block name='form_field_errors'}
                {if $field.type !== 'password'}
                {include file='_partials/form-errors.tpl' errors=$field.errors required=$field.required label=$field.label}
                {/if}
            {/block}


    </div>

{/if}

Merci beaucoup !

gouna

gouna

Bonjour,

Sur ma version de prestashop 1.7.8.11, si un client veut ajouter ou modifier son numéro de téléphone, il faut qu'il se rende dans "Adresses" puis sélectionne son adresse afin d'accéder à une page qui lui permette de modifier son numéro de téléphone. Je ne trouve pas çà très logique.

Est-il possible d'ajouter le champs de téléphonie quand on se rend dans "Mon Compte", puis dans "Informations" ? On peut modifier son mail ici donc je trouve logique qu'on puisse également modifier son numéro de téléphone, tout simplement.
Sanstitre.thumb.png.83c2115d6e73f191ad386a358ad74d9e.png

Mon fichier templates/customer/_partiel/customer-form.tpl :
 

{block name='customer_form'}

  {block name='customer_form_errors'}
    {include file='_partials/form-errors.tpl' errors=$errors['']}
  {/block}

  <form class="js-customer-form needs-validation" id="customer-form" action="{block name='customer_form_actionurl'}{$action}{/block}" method="post" novalidate autocomplete="false">
    {block name='customer_form_fields'}
      <section class="form-fields">
        {block name='form_fields'}
          {foreach from=$formFields item="field"}
            {block name='form_field'}
              {form_field field=$field}
            {/block}
          {/foreach}
          {$hook_create_account_form nofilter}
        {/block}
      </section>
    {/block}

    {block name='customer_form_footer'}
      <footer class="form-footer">
        <input type="hidden" name="submitCreate" value="1">
        {block name='form_buttons'}
          <button class="btn btn-primary form-control-submit" type="submit" data-link-action="save-customer">
            {l s='Save' d='Shop.Theme.Actions'}
          </button>
        {/block}
      </footer>
    {/block}
  </form>

{/block}


Mon fichier templates/customer/_partial/address-form.tpl :

{block name='address_form'}
  <div class="js-address-form">

    {block name='address_form_errors'}
      {include file='_partials/form-errors.tpl' errors=$errors['']}
    {/block}

    {block name='address_form_url'}
    <form
      method="POST"
      class="needs-validation"
      action="{url entity='address' params=['id_address' => $id_address]}"
      data-id-address="{$id_address}"
      data-refresh-url="{url entity='address' params=['ajax' => 1, 'action' => 'addressForm']}"
      novalidate
      autocomplete="false"
    >
    {/block}

      {block name='address_form_fields'}
        <section class="form-fields">
          {block name='form_fields'}
            {foreach from=$formFields item="field"}
              {block name='form_field'}
                {form_field field=$field}
              {/block}
            {/foreach}
          {/block}
        </section>
      {/block}

      {block name='address_form_footer'}
        <footer class="form-footer">
          <input type="hidden" name="submitAddress" value="1">
          {block name='form_buttons'}
            <button class="btn btn-primary form-control-submit" type="submit">
              {l s='Save' d='Shop.Theme.Actions'}
            </button>
          {/block}
        </footer>
      {/block}
    </form>
    
  </div>
{/block}

Fichier template/_partial/form-fields.tpl :
 

{**
 * 2007-2017 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (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:
 * https://opensource.org/licenses/AFL-3.0
 * 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 <contact@prestashop.com>
 * @copyright 2007-2017 PrestaShop SA
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *}
{$autocomplete =
['firstname' => 'given-name',
'lastname' => 'family-name',
'email'=>'email',
'password'=>'current-password',
'new_password'=>'new-password',
'postcode'=>'postal-code',
'birthday'=>'bday',
'address1'=>'street-address',
'address2'=>'address-line2',
'id_state'=>'address-level1',
'city'=>'address-level2',
'company'=>'organization'
]}
{if $field.type == 'hidden'}

    {block name='form_field_item_hidden'}
        <input type="hidden" name="{$field.name}" value="{$field.value}">
    {/block}

{else}
    {assign var=uniqId value=10|mt_rand:100000}

    <div class="form-group">
        {if $field.type == 'checkbox' || $field.type == 'radio-buttons'}
            {if $field.type == 'radio-buttons'}
                <div class="label mr-3">{$field.label}</div>
            {/if}
        {else}
            <label class="{if $field.required}required{/if}" for="f-{$field.name}_{$uniqId}">
                {$field.label}
                {block name='form_field_comment'}
                    {if (!$field.required && !in_array($field.type, ['radio-buttons', 'checkbox']))}
                            <small class="text-muted">({l s='Optional' d='Shop.Forms.Labels'})</small>
                    {/if}
                {/block}
            </label>
        {/if}


            {if $field.type === 'select'}

                {block name='form_field_item_select'}
                    <select class="custom-select{if !empty($field.errors)} is-invalid{/if}" name="{$field.name}" id="f-{$field.name}_{$uniqId}"{if $field.required} required{/if}>
                        <option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
                        {foreach from=$field.availableValues item="label" key="value"}
                            <option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
                        {/foreach}
                    </select>
                {/block}

            {elseif $field.type === 'countrySelect'}

                {block name='form_field_item_country'}
                    <select
                            class="custom-select js-country{if !empty($field.errors)} is-invalid{/if}"
                            name="{$field.name}"
                            id="f-{$field.name}_{$uniqId}"
                            {if $field.required}required{/if}
                    >
                        <option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
                        {foreach from=$field.availableValues item="label" key="value"}
                            <option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
                        {/foreach}
                    </select>
                {/block}

            {elseif $field.type === 'radio-buttons'}

                {block name='form_field_item_radio'}
                    {foreach from=$field.availableValues item="label" key="value" name="radiolist"}
                        <div class="custom-control custom-radio custom-control-inline">
                            <input
                                    name="{$field.name}"
                                    type="radio"
                                    value="{$value}"
                                    class="custom-control-input {if !empty($field.errors)} is-invalid{/if}"
                                    id="f-{$field.name}_{$uniqId}-{$smarty.foreach.radiolist.iteration}"
                                    {if $field.required}required{/if}
                                    {if $value eq $field.value} checked {/if}
                            >

                            <label class="custom-control-label" for="f-{$field.name}_{$uniqId}-{$smarty.foreach.radiolist.iteration}">{$label}</label>
                        </div>
                    {/foreach}

                {/block}

            {elseif $field.type === 'checkbox'}

                {block name='form_field_item_checkbox'}
                    <div class="custom-control custom-checkbox">
                        <input name="{$field.name}" type="checkbox" value="1" id="f-{$field.name}_{$uniqId}" class="custom-control-input{if !empty($field.errors)} is-invalid{/if}"{if $field.value} checked="checked"{/if}{if $field.required} required{/if}>
                        <label class="custom-control-label" for="f-{$field.name}_{$uniqId}">{$field.label nofilter}</label>
                    </div>
                {/block}

            {elseif $field.type === 'date'}

                {block name='form_field_item_date'}
                    <input name="{$field.name}" class="form-control{if !empty($field.errors)} is-invalid{/if}" type="date" value="{$field.value}" placeholder="{if isset($field.availableValues.placeholder)}{$field.availableValues.placeholder}{/if}" id="f-{$field.name}_{$uniqId}"{if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}>
                    {if isset($field.availableValues.comment)}
                        <span class="form-text text-muted">
              {$field.availableValues.comment}
            </span>
                    {/if}
                {/block}

            {elseif $field.type === 'birthday'}

                {block name='form_field_item_birthday'}
                    <div class="js-parent-focus">
                        {html_select_date
                        field_order=DMY
                        time={$field.value}
                        field_array={$field.name}
                        prefix=false
                        reverse_years=true
                        field_separator='<br>'
                        day_extra='class="form-control form-control-select"'
                        month_extra='class="form-control form-control-select"'
                        year_extra='class="form-control form-control-select"'
                        day_empty={l s='-- day --' d='Shop.Forms.Labels'}
                        month_empty={l s='-- month --' d='Shop.Forms.Labels'}
                        year_empty={l s='-- year --' d='Shop.Forms.Labels'}
                        start_year={'Y'|date}-100 end_year={'Y'|date}
                        }
                    </div>
                {/block}

            {elseif $field.type === 'password'}

                {block name='form_field_item_password'}
                    <div class="input-group js-parent-focus">
                        <input
                                class="form-control js-child-focus js-visible-password{if !empty($field.errors)} is-invalid{/if}"
                                name="{$field.name}"
                                id="f-{$field.name}_{$uniqId}"
                                type="password"
                                value=""
                                pattern=".{literal}{{/literal}5,{literal}}{/literal}"
                                {if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}
                                {if $field.required}required{/if}
                        >
                        <span class="input-group-btn">
              <button
                      class="btn btn-light"
                      type="button"
                      data-action="show-password"
                      data-text-show="{l s='Show' d='Shop.Theme.Actions'}"
                      data-text-hide="{l s='Hide' d='Shop.Theme.Actions'}"
              >
                {l s='Show' d='Shop.Theme.Actions'}
              </button>
            </span>
                        {include file='_partials/form-errors.tpl' errors=$field.errors required=$field.required label=$field.label}

                    </div>
                    <small class="form-text text-muted">{l s='At least 5 characters long' d='Shop.Forms.Help'}</small>

                {/block}

            {elseif $field.type === 'file'}
                <div class="custom-file">
                    <input name="{$field.name}" type="file" class="custom-file-input{if !empty($field.errors)} is-invalid{/if}" id="f-{$field.name}_{$uniqId}"{if $field.required} required{/if}>
                    <label class="custom-file-label" for="f-{$field.name}_{$uniqId}" data-browse="{l s='Choose file' d='Shop.Theme.Actions'}">{l s='Choose file' d='Shop.Theme.Actions'}</label>
                </div>
            {else}

                {block name='form_field_item_other'}
                    <input
                            class="form-control{if !empty($field.errors)} is-invalid{/if}"
                            name="{$field.name}"
                            type="{if $field.name === "phone" || $field.name === "phone_mobile"}tel{else}{$field.type}{/if}"
                            value="{$field.value}"
                            id="f-{$field.name}_{$uniqId}"
                            {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if}
                            {if $field.maxLength}maxlength="{$field.maxLength}"{/if}
                            {if $field.required}required{/if}
                            {if isset($autocomplete[$field.name])} autocomplete="{$autocomplete[$field.name]}"{/if}
                    >
                    {if isset($field.availableValues.comment)}
                        <small class="form-text text-muted">
                            {$field.availableValues.comment}
                        </small>
                    {/if}
                {/block}

            {/if}

            {block name='form_field_errors'}
                {if $field.type !== 'password'}
                {include file='_partials/form-errors.tpl' errors=$field.errors required=$field.required label=$field.label}
                {/if}
            {/block}


    </div>

{/if}

Merci beaucoup !

×
×
  • Create New...