Jump to content

How to extend max lenght of customer name


cernicektomas

Recommended Posts

The sizes are all in the $definition variable in classes/Customer.php. Let's say you have customers with really long surnames and you want to increase the maximum length to 64. You can override the maximum size by creating override/classes/Customer.php like this:
<?php

class Customer extends CustomerCore
{
    public function __construct($id = null)
    {
        CustomerCore::$definition['fields']['lastname']['size'] = 64;

        parent::__construct();
    }
}

This will increase the maximum size of the last name from 32 to 64. Note that you'll need to also edit the ps_customer table in your database using phpMyAdmin and change the size of lastname from varchar(32) to varchar(64).

 

You can add more lines like above if you need to increase the maximum size of more customer variables. You can find the names of the variables in classes/Customer.php.

 

After making these changes, go to the Advanced Parameters > Performance tab and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

Link to comment
Share on other sites

 

The sizes are all in the $definition variable in classes/Customer.php. Let's say you have customers with really long surnames and you want to increase the maximum length to 64. You can override the maximum size by creating override/classes/Customer.php like this:
<?php

class Customer extends CustomerCore
{
    public function __construct($id = null)
    {
        CustomerCore::$definition['fields']['lastname']['size'] = 64;

        parent::__construct();
    }
}

This will increase the maximum size of the last name from 32 to 64. Note that you'll need to also edit the ps_customer table in your database using phpMyAdmin and change the size of lastname from varchar(32) to varchar(64).

 

You can add more lines like above if you need to increase the maximum size of more customer variables. You can find the names of the variables in classes/Customer.php.

 

After making these changes, go to the Advanced Parameters > Performance tab and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

 

Thank you very much for the solution.

Link to comment
Share on other sites

  • 11 months later...

It is missing one thing: You have to pass the $id to the parent construct:

<?php

class Customer extends CustomerCore
{
    public function __construct($id = null)
    {
        CustomerCore::$definition['fields']['lastname']['size'] = 64;

        parent::__construct($id);
    }
}

But thanks for this code, It was really helpful.

Edited by Alsernet2000 (see edit history)
  • Like 2
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...