Jump to content

Remove "firstname" and "lastname" fields from checkout and account creation


DARKF3D3

Recommended Posts

14 minutes ago, El Patron said:

if you cannot find the code changes yourself, you should not be making the changes, and for this you open pandora's box of changes...it's core, get someone competent that did not mean you lol


We are asking here for some one to help us with the changes, I just need to know where to look because as you can see I am new to Prestashop.

Link to comment
Share on other sites

8 hours ago, El Patron said:

can you first describe why the requirement for this change, this is a very one off requirement so what know why you want to implement this is a good starting point.  

I'm in indonesia which most of the people DO NOT have last name, so it will be confusing for most people to fill out a form which they don't have.

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

Things to do, to remove lastfield:

1. Select your country via Back-office (International>Locations>Countries) and remove "lastname":

622334642_Screenshot2020-09-29at14_12_57.thumb.png.7f0e1a1ce22f3921c58cf447cdf32338.png

 

2. Change required to non-required fields in these files:

/app/classes/Address.php
/app/classes/Customer.php

From:

'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255),

To

'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 255),  // custom changed


3. Remove Javascript Check:

/app/classes/form/CustomerFormatter.php

        $format['lastname'] = (new FormField())
            ->setName('lastname')
            ->setLabel(
                $this->translator->trans(
                    'Last name',
                    [],
                    'Shop.Forms.Labels'
                )
            )
            ->setRequired(false); // set to false

4. Remove field:

/app/themes/your_theme/templates/_partials/form-fields.tpl

Add condition:

<!-- Hide lastname field, add this condition before -->
{if $field.name!='lastname'}

  <div class="form-group row {if !empty($field.errors)}has-error{/if}">
    <label class="col-md-3 form-control-label{if $field.required} required{/if}">
      {if $field.type !== 'checkbox'}
        {$field.label}
      {/if}
    </label>
    <div class="col-md-6{if ($field.type === 'radio-buttons')} form-control-valign{/if}">
      
  <...>
{/if}

 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
On 9/29/2020 at 3:23 PM, grsinternet said:

Things to do, to remove lastfield:

1. Select your country via Back-office (International>Locations>Countries) and remove "lastname":

622334642_Screenshot2020-09-29at14_12_57.thumb.png.7f0e1a1ce22f3921c58cf447cdf32338.png

 

2. Change required to non-required fields in these files:

/app/classes/Address.php
/app/classes/Customer.php

From:


'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255),

To


'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 255),  // custom changed


3. Remove Javascript Check:

/app/classes/form/CustomerFormatter.php


        $format['lastname'] = (new FormField())
            ->setName('lastname')
            ->setLabel(
                $this->translator->trans(
                    'Last name',
                    [],
                    'Shop.Forms.Labels'
                )
            )
            ->setRequired(false); // set to false

4. Remove field:

/app/themes/your_theme/templates/_partials/form-fields.tpl

Add condition:


<!-- Hide lastname field, add this condition before -->
{if $field.name!='lastname'}

  <div class="form-group row {if !empty($field.errors)}has-error{/if}">
    <label class="col-md-3 form-control-label{if $field.required} required{/if}">
      {if $field.type !== 'checkbox'}
        {$field.label}
      {/if}
    </label>
    <div class="col-md-6{if ($field.type === 'radio-buttons')} form-control-valign{/if}">
      
  <...>
{/if}

 

after doing these steps, customers are stuck at address step in checkout 

 

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...