Jump to content

Limit length of customer and customer address fields


Recommended Posts

Hello all,

I want to reduce the lenght of some customer and customer related address fields (in PS 1.7.7.2)
It is no use allowing a customer to enter up to 255 characters for their name and some address related fields if the courier does not accept more than 35 characters during their shipping label creation...

I need to limit customer data entry as follows:

firstname: max 35 characters
lastname:  max 35 characters
email: max 50 characters
company: max 35 characters

address1: max 35 characters
address2: max 8 characters
postcode: max 9 characters
city: max 35 characters
phone: max 30 characters
phone_mobile: max 30 characters

 

What is the proper way to achieve this?

Edited by KBruyninckx (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

Is my requirement so unique?

I want to implment the limits set by DPD and I assume other shopowners also use DPD to ship parcels throughout Europe.... or have you come up with another solution to avoid reworking addresses before shipping labels are created?

Or is this the wrong section of the forum for this sort of question?

Edited by KBruyninckx (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
Posted (edited)

In case anyone is interested doing this on PS8.1, you just have to edit "/classes/Address.php" file.
Here you can change the "size" value:

    // when you override this class, do not create a field with allow_null=>true
    // because it will give you exception on checkout address step
    public static $definition = [
        'table' => 'address',
        'primary' => 'id_address',
        'fields' => [
            'id_customer' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false],
            'id_manufacturer' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false],
            'id_supplier' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false],
            'id_warehouse' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false],
            'id_country' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_state' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'],
            'alias' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32],
            'company' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255],
            'lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255],
            'firstname' => ['type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255],
            'vat_number' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName'],
            'address1' => ['type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128],
            'address2' => ['type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128],
            'postcode' => ['type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12],
            'city' => ['type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64],
            'other' => ['type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300],
            'phone' => ['type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32],
            'phone_mobile' => ['type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32],
            'dni' => ['type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16],
            'deleted' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false],
            'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false],
            'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false],
        ],
    ];

 

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