Jump to content

Change fields to readonly when 'id_customer' is not null


AlainMartel

Recommended Posts

Hello.

I need to have the fields 'firstname' and 'lastname' as readonly in the "personal information" page of the front store. But I also need the client to fill them in the "Create an account" page of the front store.  We have succeeded in version 1.7.1.2 but we are not able in version 1.7.5.1.

Can any one help please?

In version 1.7.1.2, we modifying the 'themes/classic/templates/_partials/form-fields.tpl' with these modifications:

 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *}
{** NZ START *}
    {if $field.name === 'id_customer'}
            {assign var="cust_id" value={$field.value} scope="root"}
    {/if}
{* NZ END *}

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

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

{else}

...

{block name='form_field_item_other'}
          <input
            class="form-control"
            name="{$field.name}"
            type="{$field.type}"
            value="{$field.value}"
        {** NZ START *}
        {if !empty($cust_id)}
            {if $field.name === 'firstname'}readonly{/if}
            {if $field.name === 'lastname'}readonly{/if}
        {/if}
                {** NZ END *}

            {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if}
            {if $field.maxLength}maxlength="{$field.maxLength}"{/if}
            {if $field.required}required{/if}

Thanks,

Alain Martel

Edited by AlainMartel
No response (see edit history)
Link to comment
Share on other sites

  • 6 months later...

this is the solution I adopted to insert "readonly" only in the user module on the page "?controller=identity".

I hope this helps you

it work in PS 1.7.4.2

{block name='form_field_item_other'}
          <input
            class="form-control"
            name="{$field.name}"
            type="{$field.type}"
            value="{$field.value}"
            {if Tools::getValue('controller') == 'identity'}
                {if $field.name == "vat_number"}readonly{/if}
                {if $field.name == "siret"}readonly{/if}
                {if $field.name == "company"}readonly{/if}
            {/if}
            {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if}
            {if $field.maxLength}maxlength="{$field.maxLength}"{/if}
            {if $field.required}required{/if}
          >
          {if isset($field.availableValues.comment)}
            <span class="form-control-comment">
              {$field.availableValues.comment}
            </span>
          {/if}
        {/block}

 

Edited by M_UX (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...