Jump to content

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


DARKF3D3
 Share

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

11 hours ago, SnapChatScore said:

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.

for 1.7:

localization-->locations-->countries-->edit country

there you can set the required fields for customer and address

hope that helps

Share this post


Link to post
Share on other sites

On 2/19/2020 at 9:06 PM, DARKF3D3 said:

I checked on that page, there I'm able to remove those 2 fields, the problem it's that they will be removed from address.

I need to disable them from registration step only, then on address step the customer should fill these 2 fields.

Same here

Share this post


Link to post
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

Share this post


Link to post
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 

 

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More