X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Adding customer title options (https://forum.x-cart.com/showthread.php?t=78193)

bionuts 03-26-2021 02:02 AM

Adding customer title options
 
Hi all,

At present, customer title only has options for Mr, Ms and Mrs. That isn't a very inclusive list and what I want to do is either add to those options (probably the easier way to go) or make title a free text box, so that customers can enter their own text (probably more difficult, but with greatest flexibility for the customer).

I've searched through the settings and even dug around in the database and cannot find where Mr, Ms and Mrs are stored.

Any advice on how to achieve either of these options gratefully received as always.

Ed B. 03-26-2021 10:18 AM

Re: Adding customer title options
 
Where do customers choose the titles ? I can't find it in billing address and shipping address steps of check out process, or in the address book either.

cflsystems 03-26-2021 05:07 PM

Re: Adding customer title options
 
I believe these are language variables and probably hardcoded which ones to select and include in the dropdown list. You will need to find the template outputting the values and the php class responsible for it and modify it if you want to extend this.
However I find it odd that anyone will want to include this. It is very uncommon to allow something like this. No one cares to fill it out and if you modify this to allow customers to enter free text you may just end with some gibberish as value for the most part.



@Ed - it is part of the address fields setup in admin and it is off by default. I am even surprised XC5 has this included by default yet it is missing street second line and company. It makes absolutely no sense but hey it is XC after all....

Ed B. 03-27-2021 09:38 AM

Re: Adding customer title options
 
Thank you Steve.


It is hardcoded, but can be overriden easily.



The relevant lines in the class classes/XLite/View/FormField/Select/Title.php are
Code:

    protected function getDefaultOptions()
    {
        return array(
            'Mr.'  => static::t('Mr.'),
            'Ms.'  => static::t('Ms.'),
            'Mrs.' => static::t('Mrs.'),
        );


So just write a class that extends Title.php and override the method getDefaultOptions(), add labels and translations if necessary, and you will be fine.

bionuts 03-29-2021 04:01 AM

Re: Adding customer title options
 
Hi,

Thanks for your replies.

It is one of those things that divides opinion: personally, I prefer to include a title and not a full name when filling out shopping cart information; others will prefer to do the opposite.

If a customer does fill out the form without entering their full name (and many of our customers do), then having a title at least allows for emails, etc, to be more politely addressed: eg Dear Mr Smith, rather than Dear Smith.

I think our best route will be to extend the list of options, but make the field not required. That way, those that want to fill it out can and those that don't want to won't be forced to.

Thanks for your help.


All times are GMT -8. The time now is 01:17 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.