edica
edica

Reputation: 339

Modify the customer address form in prestashop 1.7 front office

I have configured this tpl for client addresses, the file is called "address-form.tpl" and has the following content

{block name="address_form"}
  <div class="js-address-form">
    {include file='_partials/form-errors.tpl' errors=$errors['']}

    {block name="address_form_url"}
    <form
      method="POST"
      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']}"
    >
    {/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 clearfix">
        <input type="hidden" name="submitAddress" value="1">
        {block name='form_buttons'}
          <button class="btn btn-primary float-xs-left" type="submit" class="form-control-submit">
            {l s='Save' d='Shop.Theme.Actions'}
          </button>
        {/block}
      </footer>
      {/block}

    </form>
  </div>
{/block}

Here the problem I have is that I loosen all the fields and renders them in the order that he wants, for example it shows me the "alias" first and then the name and surname, if what I want is to put the "alias" to end with this tpl file that I have how should I do it?

Thank you

Upvotes: 1

Views: 5297

Answers (2)

Nairo Boom
Nairo Boom

Reputation: 1

If you want to leave the "alias" field last in the form, you could use the array_reverse function, just replace the following line:

{foreach from = $formFields item = "field"} by {foreach item = "field" from = $formFields | @array_reverse: true}

Sorry for my English.

Upvotes: 0

Matt Loye
Matt Loye

Reputation: 1311

You can control this order in (for Prestashop 1.7) your backoffice : International > Locations > Countries (or Internacional > Ubicaciones Geográficas > Países ;) ) then select a country.

You should make a simple workaround, like remaking the variable used in the foreach loop so you can control the order :

 {$formFields = ["lastname","firstname","alias","..."]}

Upvotes: 0

Related Questions