Jump to content

Unable to remove "city" as required from registration/address form


Recommended Posts

Hi,

 

I have been able to remove all unnecessary fields and only have Name, Email & Address box show up in the registration field except that I am unable to remove "city" as a required field.

 

I have edited the following files during the course of hiding/non required fields:

Authcontroller.php

Authentication.tpl

order-opc-new-account.tpl

order-opc-new-order-advanced.tpl

identity.tpl

 

I have also edited the Localization > Countries and only have First Name, Lastname, Email & Address as required fields.

 

I have also edited the address.php file and made city as isrequired => false.

 

Also, addressformat.php also has only:

 public static $requireFormFieldsList = array(        'firstname',        'lastname',        'address1',        'Country:name');

While I'm able to hide the city field using the tpl, but the form still shows error - City is required.

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

  • 9 months later...
  • 2 years later...

Hi

I have a similar problem on 1.7.6.7.

I have the City field disabled but for some reason is still marked as required, and I get 500 server error when a customer attempt to add a new address.

I tried to override Address.php but it didn't work, so I ended up editing the core class similar to @rocky solution, of course I have a note to myself now: "don't forget to redo this change after updating PS".

I'm not an expert, actually I'm not even sure you can override this. Am I missing something on the override?

<?php

class Address extends AddressCore
{
	public static $definition = array(
        'table' => 'address',
        'primary' => 'id_address',
        'fields' => array(
            'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
            'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
            'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
            'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
            'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
            'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
            'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255),
            'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255),
            'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255),
            'vat_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
            'address1' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
            'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
            'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
          
            /* This was set to false for the override */
            'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => false, 'size' => 64),
          
            'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
            'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
            'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
            'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
            'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
            'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
        ),
    ); 
}

 

EDIT: duuhhh, I will also make sure to write this note: "Clear your chache"...
It is working now with the override.

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys

I comment line 125 un classes/adderess.php with /*contentLine125*/

Also i need edit any other file?

it is necessary to modify the files: 

Authcontroller.php, Authentication.tpl, order-opc-new-account.tpl, order-opc-new-order-advanced.tpl, identity.tpl ?

 

Update: excuse me. it works.

I detail the steps:

1. Delete or comment line 125 in classes/address.php

2.In locations / country remove city

 

Thanks @rocky

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