How to add new fields to the customer address in Prestashop

In today’s tutorial, we will see how to add new fields to the customer address in Prestashop.

UPDATE! If you prefer a simple solution, I created a module that automates the process and does much more, find it here

Download Project Files
  • Version used: Prestashop 1.6 (compatible with Prestashop 1.5)

Plan of action

In order to add a new field to the address registration form, we will be adding a couple of overrides, as well as creating a new database field and modifying the address template file. If you are not familiar with Prestashop overrides, check out my article on how to extend Prestashop objects (although we will have to use a slightly different technique).

The address class and database table

First things first, we need something to play with. We want the customer to be able to fill in a field which doesn’t currently exist, therefore let’s login to the database, access the ps_address table and create a new field: my_custom_field. I made it a 64 long VARCHAR field.

Next we need to tell the address object (class) that it has a new field to deal with. Create a new file inside override/classes/ and call it Address.php. Add the following inside php tags:




class Address extends AddressCore
{

	public $my_custom_field;


	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' => 64),
			'lastname' => 			array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
			'firstname' => 			array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
			'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),
			'city' => 				array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, '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' => 'isDateFormat', 'copy_post' => false),
			'date_upd' => 			array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
			'my_custom_field' => 	array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),

		),
	);
}

Explanation: if you read my article on how to extend Prestashop Objects, you will notice I approached this override a little differently. I am not assigning the new field upon instance creation, but I am directly overriding its definition. The reason is simple: the Address definition is called statically when creating a new address in the front office, and if we added the new field in the construct method, we would have missed it from the list.

Please notice that this definition comes from Prestashop 1.6.0.5, and I therefore recommend to use your own from the original Address class, in case you have a different Prestashop version.

The back office Address Controller

We are half the way through already, and at this point we need to override the back office controller responsible for displaying the address modification form for each customer.

Create a new file named AdminAddressesController.php in override/controllers/admin/. We need to extend the renderForm() method; thus, head over the main controllers/admin folder, open up the original AdminAddressesController.php, locate the renderForm() method and copy it. Then, add the following inside php tags in our new controller override:


Class AdminAddressesController extends AdminAddressesControllerCore
{

}

And paste the renderForm() code inside the class. Here is how mine looks like, taken from Prestashop 1.6.0.5:


Class AdminAddressesController extends AdminAddressesControllerCore
{


	public function renderForm()
	{
		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Addresses'),
				'icon' => 'icon-envelope-alt'
			),
			'input' => array(
				array(
					'type' => 'text_customer',
					'label' => $this->l('Customer'),
					'name' => 'id_customer',
					'required' => false,
				),
				array(
					'type' => 'text',
					'label' => $this->l('Identification Number'),
					'name' => 'dni',
					'required' => false,
					'col' => '4',
					'hint' => $this->l('DNI / NIF / NIE')
				),			
				array(
					'type' => 'text',
					'label' => $this->l('Address alias'),
					'name' => 'alias',
					'required' => true,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' <>;=#{}'
				),
				array(
					'type' => 'text',
					'label' => $this->l('Home phone'),
					'name' => 'phone',
					'required' => false,
					'col' => '4',
					'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : ''
				),
				array(
					'type' => 'text',
					'label' => $this->l('Mobile phone'),
					'name' => 'phone_mobile',
					'required' => false,
					'col' => '4',
					'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : ''
				),
				array(
					'type' => 'textarea',
					'label' => $this->l('Other'),
					'name' => 'other',
					'required' => false,
					'cols' => 15,
					'rows' => 3,
					'hint' => $this->l('Forbidden characters:').' <>;=#{}'
				),
			),
			'submit' => array(
				'title' => $this->l('Save'),
			)
		);
		$id_customer = (int)Tools::getValue('id_customer');
		if (!$id_customer && Validate::isLoadedObject($this->object))
			$id_customer = $this->object->id_customer;
		if ($id_customer)
		{
			$customer = new Customer((int)$id_customer);
			$token_customer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
		}

		$this->tpl_form_vars = array(
			'customer' => isset($customer) ? $customer : null,
			'tokenCustomer' => isset ($token_customer) ? $token_customer : null
		);

		// Order address fields depending on country format
		$addresses_fields = $this->processAddressFormat();
		// we use  delivery address
		$addresses_fields = $addresses_fields['dlv_all_fields'];

		$temp_fields = array();

		foreach ($addresses_fields as $addr_field_item)
		{
			if ($addr_field_item == 'company')
			{
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('Company'),
					'name' => 'company',
					'required' => false,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' <>;=#{}'
				);
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('VAT number'),
					'col' => '2',
					'name' => 'vat_number'
				);
			}
			else if ($addr_field_item == 'lastname')
			{
				if (isset($customer) &&
					!Tools::isSubmit('submit'.strtoupper($this->table)) &&
					Validate::isLoadedObject($customer) &&
					!Validate::isLoadedObject($this->object))
					$default_value = $customer->lastname;
				else
					$default_value = '';

				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('Last Name'),
					'name' => 'lastname',
					'required' => true,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:',
					'default_value' => $default_value,
				);
			}
			else if ($addr_field_item == 'firstname')
			{
				if (isset($customer) &&
					!Tools::isSubmit('submit'.strtoupper($this->table)) &&
					Validate::isLoadedObject($customer) &&
					!Validate::isLoadedObject($this->object))
					$default_value = $customer->firstname;
 	 	 	 	else
 	 	 	 		$default_value = '';

				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('First Name'),
					'name' => 'firstname',
					'required' => true,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:',
					'default_value' => $default_value,
				);
			}
			else if ($addr_field_item == 'address1')
			{
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('Address'),
					'name' => 'address1',
					'col' => '6',
					'required' => true,
				);
			}
			else if ($addr_field_item == 'address2')
			{
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('Address').' (2)',
					'name' => 'address2',
					'col' => '6',
					'required' => false,
				);
			}
			elseif ($addr_field_item == 'postcode')
			{
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('Zip/Postal Code'),
					'name' => 'postcode',
					'col' => '2',
					'required' => true,
				);
			}
			else if ($addr_field_item == 'city')
			{
				$temp_fields[] = array(
					'type' => 'text',
					'label' => $this->l('City'),
					'name' => 'city',
					'col' => '4',
					'required' => true,
				);
			}
			else if ($addr_field_item == 'country' || $addr_field_item == 'Country:name')
			{
				$temp_fields[] = array(
					'type' => 'select',
					'label' => $this->l('Country'),
					'name' => 'id_country',
					'required' => false,
					'col' => '4',
					'default_value' => (int)$this->context->country->id,
					'options' => array(
						'query' => Country::getCountries($this->context->language->id),
						'id' => 'id_country',
						'name' => 'name'
					)
				);
				$temp_fields[] = array(
					'type' => 'select',
					'label' => $this->l('State'),
					'name' => 'id_state',
					'required' => false,
					'col' => '4',
					'options' => array(
						'query' => array(),
						'id' => 'id_state',
						'name' => 'name'
					)
				);
			}
		}

		// merge address format with the rest of the form
		array_splice($this->fields_form['input'], 3, 0, $temp_fields);

		return parent::renderForm();
	}
	
}

We must edit the $this->fields_form variable to add a new input field; right after this:

				array(
					'type' => 'text',
					'label' => $this->l('Identification Number'),
					'name' => 'dni',
					'required' => false,
					'col' => '4',
					'hint' => $this->l('DNI / NIF / NIE')
				),	

Add the following

				array(
					'type' => 'text',
					'label' => $this->l('My custom field'),
					'name' => 'my_custom_field',
					'required' => false,
					'col' => '4',
					'hint' => $this->l('Just a custom field!')
				),	

Note: make sure the “name” matches the one of the new attribute previously added to both the database and Address class object!

Lastly, at the end of the method, change:

return parent::renderForm();

To

return AdminController::renderForm();

So that the new fields list is not replaced by the original one.

If the Address class or/and controller were not previously overridden, at this point you must reach the cache/ folder and erase class_index.php; as always. After doing it, overrides will take place.

The Front Office Address Template

As very last step, let’s now add the custom field to the front office template, so it can be filled in by clients when they register. Open up address.tpl, located in the theme folder. I am using the default bootstrap template, so your file might look differently in case you have a custom one! Locate:


			{if $field_name eq 'vat_number'}
				<div id="vat_area">
					<div id="vat_number">
						<div class="form-group">
							<label for="vat-number">{l s='VAT number'}</label>
							<input type="text" class="form-control validate" data-validate="{$address_validation.$field_name.validate}" id="vat-number" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{else}{if isset($address->vat_number)}{$address->vat_number|escape:'html':'UTF-8'}{/if}{/if}" />
						</div>
					</div>
				</div>
			{/if}

And right after it, add:


			{if $field_name eq 'my_custom_field'}
				<div id="vat_area">
					<div id="my_custom_field">
						<div class="form-group">
							<label for="my-custom-field">{l s='My Custom Field'}</label>
							<input type="text" class="form-control validate" data-validate="{$address_validation.$field_name.validate}" id="my-custom-field" name="my_custom_field" value="{if isset($smarty.post.my_custom_field)}{$smarty.post.my_custom_field}{else}{if isset($address->my_custom_field)}{$address->my_custom_field|escape:'html':'UTF-8'}{/if}{/if}" />
						</div>
					</div>
				</div>
			{/if}

Save and refresh, we’re done!

TIP: if you don’t see any change in the front office, make sure you turn on recompilation from Advanced Parameters > Performance, and clear Smarty cache as well

Optional: Making the new field mandatory

If you really need your customers to input something in that new field, than another override is necessary. Create a new file within override/controllers/front and call it AddressController.php. Paste the following inside php tags, ad always:


Class AddressController extends AddressControllerCore
{

}

We need to override the processSubmitAddress() method. Therefore, if your Prestashop version is not 1.6.0.5, go ahead and copy your original one inside this new override; otherwise you can use the following:


	protected function processSubmitAddress()
	{
		$address = new Address();
		$this->errors = $address->validateController();
		$address->id_customer = (int)$this->context->customer->id;

		// Check page token
		if ($this->context->customer->isLogged() && !$this->isTokenValid())
			$this->errors[] = Tools::displayError('Invalid token.');

		// Check phone
		if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
			$this->errors[] = Tools::displayError('You must register at least one phone number.');
		if ($address->id_country)
		{
			// Check country
			if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
				throw new PrestaShopException('Country cannot be loaded with address->id_country');

			if ((int)$country->contains_states && !(int)$address->id_state)
				$this->errors[] = Tools::displayError('This country requires you to chose a State.');

			$postcode = Tools::getValue('postcode');		
			/* Check zip code format */
			if ($country->zip_code_format && !$country->checkZipCode($postcode))
				$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
			elseif(empty($postcode) && $country->need_zip_code)
				$this->errors[] = Tools::displayError('A Zip/Postal code is required.');
			elseif ($postcode && !Validate::isPostCode($postcode))
				$this->errors[] = Tools::displayError('The Zip/Postal code is invalid.');

			// Check country DNI
			if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
				$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
			else if (!$country->isNeedDni())
				$address->dni = null;
		}
		// Check if the alias exists
		if (!$this->context->customer->is_guest && !empty($_POST['alias']) && (int)$this->context->customer->id > 0)
		{
			$id_address = Tools::getValue('id_address');
			if(Configuration::get('PS_ORDER_PROCESS_TYPE') && (int)Tools::getValue('opc_id_address_'.Tools::getValue('type')) > 0)
				$id_address = Tools::getValue('opc_id_address_'.Tools::getValue('type'));
 	
			if (Db::getInstance()->getValue('
				SELECT count(*)
				FROM '._DB_PREFIX_.'address
				WHERE `alias` = \''.pSql($_POST['alias']).'\'
				AND id_address != '.(int)$id_address.'
				AND id_customer = '.(int)$this->context->customer->id.'
				AND deleted = 0') > 0)
				$this->errors[] = sprintf(Tools::displayError('The alias "%s" has already been used. Please select another one.'), Tools::safeOutput($_POST['alias']));
		}

		// Check the requires fields which are settings in the BO
		$this->errors = array_merge($this->errors, $address->validateFieldsRequiredDatabase());

		// Don't continue this process if we have errors !
		if ($this->errors && !$this->ajax)
			return;

		// If we edit this address, delete old address and create a new one
		if (Validate::isLoadedObject($this->_address))
		{
			if (Validate::isLoadedObject($country) && !$country->contains_states)
				$address->id_state = 0;
			$address_old = $this->_address;
			if (Customer::customerHasAddress($this->context->customer->id, (int)$address_old->id))
			{
				if ($address_old->isUsed())
					$address_old->delete();
				else
				{
					$address->id = (int)($address_old->id);
					$address->date_add = $address_old->date_add;
				}
			}
		}
		
		if ($this->ajax && Tools::getValue('type') == 'invoice' && Configuration::get('PS_ORDER_PROCESS_TYPE'))
		{
			$this->errors = array_unique(array_merge($this->errors, $address->validateController()));			
			if (count($this->errors))
			{
				$return = array(
					'hasError' => (bool)$this->errors,
					'errors' => $this->errors
				);
				die(Tools::jsonEncode($return));
			}
		}
		
		// Save address
		if ($result = $address->save())
		{			
			// Update id address of the current cart if necessary
			if (isset($address_old) && $address_old->isUsed())
				$this->context->cart->updateAddressId($address_old->id, $address->id);
			else // Update cart address
				$this->context->cart->autosetProductAddress();

			if ((bool)(Tools::getValue('select_address', false)) == true OR (Tools::getValue('type') == 'invoice' && Configuration::get('PS_ORDER_PROCESS_TYPE')))
				$this->context->cart->id_address_invoice = (int)$address->id;
			elseif (Configuration::get('PS_ORDER_PROCESS_TYPE'))
				$this->context->cart->id_address_invoice = (int)$this->context->cart->id_address_delivery;
			$this->context->cart->update();

			if ($this->ajax)
			{
				$return = array(
					'hasError' => (bool)$this->errors,
					'errors' => $this->errors,
					'id_address_delivery' => (int)$this->context->cart->id_address_delivery,
					'id_address_invoice' => (int)$this->context->cart->id_address_invoice
				);
				die(Tools::jsonEncode($return));
			}

			// Redirect to old page or current page
			if ($back = Tools::getValue('back'))
			{
				if ($back == Tools::secureReferrer(Tools::getValue('back')))
					Tools::redirect(html_entity_decode($back));
				$mod = Tools::getValue('mod');
				Tools::redirect('index.php?controller='.$back.($mod ? '&back='.$mod : ''));
			}
			else
				Tools::redirect('index.php?controller=addresses');
		}		
		$this->errors[] = Tools::displayError('An error occurred while updating your address.');
	}

Right before the // CHeck Phone comment, add:

		if ( !Tools::getValue('my_custom_field'))
			$this->errors[] = Tools::displayError('The custom field is mandatory!');

So that an error will be thrown if your clients leave that field empty!

Remember to erase the class index file again, of course.

Adding the new field to the address format in Prestashop

As a side note, be aware that in order to display the new field we added we need to change the address format for each country. I am not currently aware of a simple way to apply address changes to all countries at once. Therefore, head over to Localization > Countries, click on a country name and add the new field to the address box:

Adding the new field to the address format in Prestashop

What for new Customer Fields?

Throughout this tutorial, we added a new field to the Address object. However, it is also possible to create a new basic customer field, to sit along name, lastname and email in the very basic registration (even without an address). To do so, you can simply apply the same process to the Customer class, and relative controllers. Just be aware that you will need to edit a couple of different template files: identity.tpl and authentication.tpl, as well as order-opc-new-account.tpl if you use the one page checkout!

UPDATE! If you prefer a simple solution, I created a module that automates the process and does much more, find it here

Additional Resources

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • Luis Ruben Perez Gil

    Hello, thanks for the tutorial, but, this not work in prestashop 1.7.6.5?

  • Francisco Javier Falcón Ortiz

    Hello,

    Your tutorial has been very helpful to me,

    I now need to add a checkbox field to the address form, but I can’t save the checkbox value…

    Can you help me?

    • jackandco44

      Have you been able to solve your problem? I have exactly the same one with radio field. The value is correctly stored in the database but is not displaying in admin nor front when updating the form.

  • Mario Herrera

    Hello, I have read very carefully your guide and I am wondering if this guide could apply for Prestashop 1.7 because I need to apply this guide in order to add a new custom_field on address form.

  • 7stars

    Hello, is there anything to be done on AuthController.php ? How that field (or more than one…) is recognized by the controller and saved to database? And then, why if you write {if $field_name eq ‘myfield’} with “myfield” or other name set, the fields are not there on the form? Are you sure that Address.php is enough? Thank you

    • 7stars

      Sorry, I was wrong… I forgot to “Adding the new field to the address format in Prestashop” because, otherwise the $field_name obviously can’t be properly set…

  • Jordans

    Excelente aporte mi estimado muy agradecido. Disculpa tambien podrias poner uno en donde podamos validar solo numeros en el campo telefono o celular y letras en nombres? gracias quedo atento

  • Χρηστος Δουσμανοπουλος

    Hello,
    I followed the instructions and worked. I used this topic to create extra fields for my client to have the abillity invoice when are in checkout. The problem is that if I try to do the order and I will not choose to have an invoice and I cannot save the information I give because it needs to fill the new fields I created. By the way I haven’t these fields required
    Thanks
    https://uploads.disquscdn.com/images/6f3d49f91cd0869755315aa965b17f7bafe03d175f232b98cc63ee74b4cc188f.png https://uploads.disquscdn.com/images/6f3d49f91cd0869755315aa965b17f7bafe03d175f232b98cc63ee74b4cc188f.png
    https://uploads.disquscdn.com/images/02710f2c88f9e8798c3e6b7e55e0bca47e2e2db27394519a225aff16c88e84de.png

  • Fotis

    Thank you Nemo, your tutorial is excellent!

    I followed your instructions and I (almost) succeded on making the modifications I wanted to do, which is to add 2 new fields in address (proffesion and vat authority), both required if a customer wants us to issue an invoice instead of a sales receipt in my country.

    I had no problem adding the proffesion field, I even used the VAT number js and the same id, in order to make it pop-up only when the visitor writes in “company” field, but I cannot get “vat authority” to work. The difference with this field, is that I want it to work with a select input, just like states or countries. I have created a table in my database with all the existing vat authority offices of my country (with columns: id, name, active), and I added the following in the AdminAddressController.php file in override folder, right after the “vat number” definition and before my custom “proffesion”:
    $temp_fields[] = array(
    ‘type’ => ‘select’,
    ‘label’ => $this->l(‘VAT authority’),
    ‘name’ => ‘id_doy’,
    ‘required’ => in_array(‘id_doy’, $required_fields),
    ‘col’ => ‘2’,
    ‘default_value’ => ‘0’,
    ‘options’ => array(
    ‘query’ => array(),
    ‘id’ => ‘id_doy’,
    ‘name’ => ‘name’
    )
    );
    But the “id_doy” field does not appear in backoffice’s address format setup, so I cannot get it to show up in front office, or to continue with testing (connecting it with the db to get the names array etc).
    I noticed, that a db query command is used in the original controller file for the countries field. Must I do the same? Mind that, there is no such query command for the “states” field, although it is also a select input.
    Does a new class need to be created for my “id_doy” field? I ask this, because I saw in the address format setup in b.o., that the country name must be entered in a “Country:name” format.

    I also wanted to ask you, what value should I use for the ‘col’ parameter. I have tried both 2 and 4.

    Any suggestions will be appreciated. Thank you in advance.

    • Fotis

      Well, I managed to get it to work, up to some point.
      I finally created a new class in classes and my class appeared in backoffice so I managed to include it in address format. I also created an AddressController.php file in overrides folder, extending the initContent function and creating a new function, in order to assign the names I needed to an array which I (think) I pass to the tpl file. The select input in front office finally appeared, but it is not populated… I don’t know what I am doing wrong… :(

  • Paul

    Hey great! It worked on a prestashop 1.6.x but now our customers want to migrate to 1.7 and I’m not sure how to proceed because now everything has changed. I decided to buy this module:

    http://addons.prestashop.com/en/registration-ordering-process/20594-custom-registration.html

    It’s installed well, you can configure everything but it doesn’t display the new fields into the registration process.
    Some clue? I’m stucked.

    Thanks in advance.

    • NemoPS

      There is no reason to downgrade to 1.7, I would try to convince customers it’s a bad option. They would lose 90% of the features they have

      • Paul

        Thanks for your answer!
        Yes I think so, but in some prestashop migrations we are having strange behaviours like backend not working properly and so on… I think it’s because differente PHP versions…This was the main reason to think about new 1.7 version.

        So we’re doing some hacks, but as more patches we do more difficult will be to migrate in a future. This new version of prestashop looks good inside the code but there’s no documentation at all. Not enought to solve problems.

        For now if it’s useful for somebody we’re compiling many different PHP versions on the new servers and telling apache what version to use for each case.

      • http://bestcmsplugins.com/ Jawad Tahir

        I was just checking your post and comments and I saw that you used the word downgrade to 1.7. It is very strange to me as for newer version upgrade is used. It shows that you are not OK with 1.7.
        I know that you are an expert so please guide me that I have installed version 1.6 on my store. Either it will be better to upgrade it to 1.7 or I continue using 1.6?

  • Liviu Valentin MOLDOVAN

    Hello friends,

    I use version 1.6.1.4 and I want to say that I followed the steps recommended by the Nemo and I have a remark:

    – if I am a new customer and I want to create my account, after entering my e-mail address, in the “CREATE AN ACCOUNT” page, “my_custom_field” does not occur.

    – Instead, after I made my account, “my_custom_field” appear in both situations when I add a new address or I want to change/modify an existing one.

    I prefer that “my_custom_field” to occur even at the beginning at the account creation.

    I missed something in the steps taken by Nemo in his tutorial?

    Many thanks in advance!

    Liviu.

    • NemoPS

      Liviu,
      That needs another approach, as mentioned in the tut. You need to modify IdentityController, the Customer class instead of address, as well as identity.tpl :)

  • Edvinas Gurevičius

    Me too!!!.. Have you found a solution?

  • Yano Barbe

    Ok guys for those having problems with fields not displaying in the front office just change this :

    {if $field_name eq ‘your_field_name’}

    to this:

    {if $field_name eq ‘my_custom_field’}
    in your tpl file. Because the variable name created by Nemo and set in your Localization is this ‘my_custom_field’ not your newly created one.

  • Иван Фиала

    PS 1.6.1.1 worked. THX

  • Luca

    Hi,
    in my shop (1.5 version) the default state is Italy.
    If i insert the “custom field” in the italy address layout it appear in all of state, and it dosen’t disappear if i change state in the customer address front office page.

    I need that this custom field appears only if the user, when is in the new address page, select particular state… is possible?

    Thanks best regards!

    • NemoPS

      This is normal as you are just adding a new field overall. What your ask requires a more complicated solution, integrated with javascript on the change event of the states dropdown

  • Tom Wiblin

    Hi Nemo,

    Thanks for the tutorial, I was able to add text fields with ease using this tutorial.

    I also need to add a date field to the Address page, is this possible?

    Many thanks,
    Tom

    • NemoPS

      Hi Tom!
      Yeah, you can adapt this for the front datepicker
      http://nemops.com/adding-a-datepicker-to-prestashop-customization-fields/#.VdI6Evnzrmg
      And use ‘type’ => ‘datetime’, with the back office helper

      • Tom Wiblin

        Hi again Nemo,

        I have added the date picker to the front and back office. The back office works fine. However the front office date picker is not saving the date correctly. It is saving any date I pick as 0000-00-00, rather than the correct date. Is there something I’ve missed?

        Kind regards,
        Tom

        • Tom Wiblin

          No, my apologies, I’ve discovered that it is saving the date in spite of the validation error, but none of the custom fields seem to be displayed in the database.

  • Fabio

    to those who can not display it in the FO .. in version 1.6.0.11

    add this to authentication.tpl:

    {elseif $field_name eq ‘my_custom_field’}

    {l s=’My Custom Field’}

    after this line:

    {if isset($PS_REGISTRATION_PROCESS_TYPE) && $PS_REGISTRATION_PROCESS_TYPE}

    between other fields…

    hope this help

  • true

    Yup, it seems that there’s a problem with the display in front-office in the latest versions, i have the same problem :s Appears in BO but not in FO, 1.6.0.14. Any ideas ? i added the closing php tags to my php files, but did not work.

Store Top Sales

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: