John Doe
John Doe

Reputation: 11

Require 'Alias' field when entering first address / adding one while in check-out process. (PS 1.7)

I've already taken a look into FormField.php and CustomerAddressFormatter.php and couldn't quite figure it out. 

What I'm trying to achieve is:

To display the 'alias' field while a customer adds his first (or an following) address via checkout. As of now that field is only visible if editing an address in the 'your account' page. Make the 'alias' field required.  Given that the difference in fields between adding an address outside of the 'your account' page and the one in the account-page equals 10 vs. 11, I figured there must be two different .php files and that the adjustment must be relatively quick and simple. However, after spending 7 hours on it so far, I figured I'll ask for help in locating the relevant files.

After some further search I found the address-form.tpl to contain the relevant section. I now got the alias to show in the desired spot. What I'm now struggling with is making it be required. I suspect CustomerAddressFormatter.php to be the relevant file.

Upvotes: 1

Views: 1385

Answers (1)

defuzed
defuzed

Reputation: 568

Like I said as a comment to your other question, the alias field is already required by default.

The reason it might seem like it is not, is, i believe, this little piece of code in CustomerAddressForm.php:

if (empty($address->alias)) {
    $address->alias = $this->translator->trans('My Address', [], 'Shop.Theme.Checkout');
}

Which fills the field with the translation for "My Address". So as a simple way of enforcing input into that field, just remove that line (in an override of course!). You probably should add some real validation and appropriate error messages as well (not sure if it might not already be there).

To add a little context to this: The alias field used to be displayed by default in PS version < 1.7. This caused a lot of irritation since this field is pretty much unique to prestashop webshops and customers often didn't know what it was for.

Upvotes: 1

Related Questions