Jump to content

Address.tpl Two phone required


Takis

Recommended Posts

Hi,

I could have your assistance on how to do the two fields to be required;

Currently fileds phone & mobile

 

It is not useful for us the choice of "at least one"

 

If there is anything I can do I would appreciate your help

 

 

PS: we refer to address.tpl
 

 

Thanks in advance

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

You'll need to create override/class/Address.php with the following:

<?php

class Address extends AddressCore
{
    public function __construct($id_address = null, $id_lang = null)
    {
        self::$definition['fields']['phone']['required'] = true;
        self::$definition['fields']['phone_mobile']['required'] = true;
        parent::__construct($id_address, $id_lang);
    }
}

Then go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. This will cause an error message to be displayed if either the "Home phone" or "Mobile phone" fields are empty.

 

Once you've done that, you can edit address.tpl to change <sup>**</sup> to <sup>*</sup> and remove the following code:

		{if isset($one_phone_at_least) && $one_phone_at_least && !$atLeastOneExists}
			<p class="inline-infos required">{l s='You must register at least one phone number.'}</p>
		{/if}

This will make it clearer to the customer that both phone numbers are required.

Link to comment
Share on other sites

  • 2 weeks later...

Hi again,

I have the following problem.
About the above code all really work as I would like.
But we have a problem when we enabled the option for guests that can make buys

 

In the point on the address information, there is the field of a phone and no two, and all the informations we have completed, we get an error that the phone is missing. In fact there is this option at least in the point that mention

 

I hope I was able to explain correctly

 

 

Thanks in advance

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...