Zen Cart Logo
Forums / General Questions / Add a field into create account

Add a field into create account

Views: 51,593

Results 1 to 20 of 138
16 Aug 2007, 11:11 PM
#1
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Add a field into create account

Hello, I want to add a field into the create account page (when a customer is creating a new account).

I think I am on the right track but I need some help, this is what I have done so far...

  1. I added a column to the customers table in the MySQL database (called customers_taxid)

  2. I edited the:
    includes/templates/MYTEMPLATE/templates/tpl_modules_create_account.php
    and added the field

  3. THIS IS WHERE I AM STUCK I do not know how to get the new field I just added to write its contents into the database

  4. I edited the customers.php file in admin/customers.php to show the new field when I view the customers information (of course at this time the field is always blank since I do not know step 3)

Can someone please help, and explain to me how to make step 3 happen and of course if I am overlooking something else please let me know as well.

Thank you.
P.S. I did try the new add-a-field module but it did not work for me and I had to resort back to my backup files (and I spent hours on trying to get that to work, reading every post in the help forums).

17 Aug 2007, 2:05 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Add a field into create account

The validation and saving of the collected data is handled by:
/includes/modules/YOURTEMPLATE/create_account.php

19 Aug 2007, 5:05 PM
#3
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Re: Add a field into create account

Thank you Dr. Byte, everything works great!

I figured I will now post exactly what I did, in hopes to help anyone else out there looking to add a field into the create account form (this is the form the customer must fill out on the login page, if they do not have a login yet and want to register with your website.)

Please backup everything before trying this and please understand I am posting this in order to help anyone else looking to do what I did, I make no guarantees of any kind and I assume no liability if anything bad happens.

Here we go:

  1. Go to PHPMyAdmin and select your database from the pulldown.
  2. On the left sidebar of PHPMyAdmin click on the table "customers"
  3. On the right side of the screen you will see all the fields like customers_telephone, customers_fax and so-on... Now scroll below this and you should see a way to add a field, in mine I saw:

Add = 1, Fields = At end of table, Then I clicked "GO"

This sent me to another page to name my field and stuff so I named it "customers_taxid" (no quotation marks). Then I selected "VarChar" and a length of "32", Collation = (it was blank and I left it blank), Attributed = (it was blank and I left it blank), Null = NULL

Then I clicked "SAVE"

  1. I then saw my new field in the table it was on the bottom of all the other ones that were previously there.

  2. Close PHPMyAdmin

  3. Open file includes/modules/YOURTEMPLATE/create_account.php
    (or if your template did not override this then simply use the one in modules folder)

7a. Now search for the following:

$fax = zen_db_prepare_input($_POST['fax']);

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

$taxid = zen_db_prepare_input($_POST['taxid']);

7b. Next search for:

'customers_fax' => $fax,

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

'customers_taxid' => $taxid,

  1. Now open file: includes/tamplates/YOURTEMPLATE/templates/tpl_module_create_account.php

  2. Search for the following code:

<legend><?php echo TABLE_HEADING_PHONE_FAX_DETAILS; ?></legend>

this is the heading for the section on the form that houses the telephone number and fax number inputs, I changed it to this:

<legend><?php echo 'Additional Information'; ?></legend>

this allowed my heading to say "Additional Information" instead of the original text of "Additional Contact Details" *

*Please note: if you preffer to edit the variable "TABLE_HEADING_PHONE_FAX_DETAILS" go to includes/languages/english.php it is in there

9a. Now search for the following code:

<?php if (ACCOUNT_FAX_NUMBER == 'true') { ?> <br class="clearBoth" /> <label class="inputLabel" for="fax"><?php echo ENTRY_FAX_NUMBER; ?></label> <?php echo zen_draw_input_field('fax', $account->fields['customers_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?> <?php } ?>

DO NOT ERASE THE ABOVE CODE, ONLY PASTE THE NEW LINES OF CODE BELOW THE CODE ABOVE, here is the new code to paste under the code above:

<br class="clearBoth" /> <label class="inputLabel" for="taxid"><?php echo 'Tax ID Number:'; ?></label> <?php echo zen_draw_input_field('taxid', $account->fields['customers_taxid'], 'id="taxid"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>
  1. Now go to Admin/customer.php and edit this file.
    (editing this file will allow you to see the taxid field when you edit customer information in the administrative section)

  2. Search for:

$customers_fax = zen_db_prepare_input($_POST['customers_fax']);

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

$customers_taxid = zen_db_prepare_input($_POST['customers_taxid']);

11a. Now search for:

'customers_fax' => $customers_fax,

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

'customers_taxid' => $customers_taxid,

11b. Now search for:

a.entry_country_id, c.customers_telephone, c.customers_fax,

REPLACE THIS CODE WITH THE FOLLOWING CODE BELOW:

a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_taxid,

(ALL I DID WAS ADD "c.customers_taxid," TO THE END OF THE EXISTING CODE.)

11c. Now search for:

<tr> <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td> <td class="main"> <?php if ($processed == true) { echo $cInfo->customers_fax . zen_draw_hidden_field('customers_fax'); } else { echo zen_draw_input_field('customers_fax', $cInfo->customers_fax, zen_set_field_length(TABLE_CUSTOMERS, 'customers_fax', 15)); } ?> </td>

DO NOT ERASE THIS CODE SIMPLY GO DIRECTLY UNDER THIS CODE AND ADD IN THE FOLLOWING CODE:

<tr> <td class="main"><?php echo 'Tax ID:'; ?></td> <td class="main"> <?php if ($processed == true) { echo $cInfo->customers_taxid . zen_draw_hidden_field('customers_taxid'); } else { echo zen_draw_input_field('customers_taxid', $cInfo->customers_taxid, zen_set_field_length(TABLE_CUSTOMERS, 'customers_taxid', 15)); } ?> </td>
  1. All done it should now work, if it doesnt, that is why you made a backup before doing this.

Good luck I hope this helps!

19 Aug 2007, 6:03 PM
#4
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Re: Add a field into create account

Hello Dr. Byte,

Can you please assist me one more time by letting me know which file writes the data from the address book entries (when a customer clicks on "add address") to the database?

I want to add an additional field in the "add address" form.

Thank You.

19 Aug 2007, 6:09 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Add a field into create account

xlr82quik:

Can you please assist me one more time by letting me know which file writes the data from the address book entries (when a customer clicks on "add address") to the database?

I want to add an additional field in the "add address" form.

There are likely multiple places depending on what you're trying to do.
see the header_php.php in the /includes/modules/pages/address_book_process folder
or maybe /includes/modules/YOURTEMPLATE/checkout_address_book.php
or maybe /includes/modules/YOURTEMPLATE/checkout_new_address.php
and the various template files associated with them
And there's also the admin/customers.php if you want to see/edit via the admin

19 Aug 2007, 9:16 PM
#6
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Re: Add a field into create account

Hello, I appreciate all the help, I did edit all files you mentioned and the data is going into the database but for some reason I can not see the data in the address book overveiw and also when I click through to edit the address book entry the data for the new field appears as blank (but I know it is in the DB since I use PHPMyAdmin to check).

I assume I will need to edit another file to display the data in the address book overview, I just dont know which file...

And I guess I am just missing something in the file:
includes/templates/MYTEMPLATE/templates/tpl_modules_address_book_details.pgp

I was trying to add a fax number field to the address book entry, this is the code I used (in above mentioned file):

<label class="inputLabel" for="fax"><?php echo 'Fax Number:'; ?></label>

<?php echo zen_draw_input_field('fax', $entry->fields['entry_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>
21 Aug 2007, 9:11 PM
#7
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Re: Add a field into create account

Hello, I know you are very busy and appreciate your help very much, just wanted to see if you may have had an answer on my last question...

22 Aug 2007, 4:28 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Add a field into create account

The way I'd find out is to search for TABLE_ADDRESS_BOOK in the files under the includes folder. Look for all the SELECT statements that extract several fields. In the file that relates to the page you're wanting to see this change on, make sure your fax field is included in the select or else your attempts to use that field will show blanks.

23 Aug 2007, 1:54 AM
#9
rdhinman avatar

rdhinman

New Zenner

Join Date:
Sep 2005
Location:
Spencer, MA
Posts:
35
Plugin Contributions:
0

Re: Add a field into create account

xlr82quik:

9a. Now search for the following code:

<?php if (ACCOUNT_FAX_NUMBER == 'true') { ?> <br class="clearBoth" /> <label class="inputLabel" for="fax"><?php echo ENTRY_FAX_NUMBER; ?></label> <?php echo zen_draw_input_field('fax', $account->fields['customers_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?> <?php } ?>

DO NOT ERASE THE ABOVE CODE, ONLY PASTE THE NEW LINES OF CODE BELOW THE CODE ABOVE, here is the new code to paste under the code above:

<br class="clearBoth" /> <label class="inputLabel" for="taxid"><?php echo 'Tax ID Number:'; ?></label> <?php echo zen_draw_input_field('taxid', $account->fields['customers_taxid'], 'id="taxid"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>

Hello,

I have a client who needs to add a TAX ID field for reseller authentication purposes. I have read through your example, and I really appreciate your efforts, but I am confused about something.

In the snippet above, you instruct that your suggested code should be added below the provided original code. My question is, why do you repeat the ENTRY_FAX_NUMBER_TEXT portion of the code. It doesn't appear to have anything to do with the TAX ID. Here is the portion I am referring to: ```
. (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>':"); ?>


Is this required just as a means to complete the statement?  Shouldn't there be a corresponding finishing section similar to: 

. (zen_not_null(ENTRY_TAXID_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_TAXID_NUMBER_TEXT . '</span>':"); ?>


Thanks in advance.

Bob
24 Aug 2007, 9:40 PM
#10
xlr82quik avatar

xlr82quik

New Zenner

Join Date:
Feb 2007
Posts:
16
Plugin Contributions:
0

Re: Add a field into create account

It wont matter, because this portion of the code is irrelevant for our purposes, and since I did not define the text for "ENTRY_TAXID_NUMBER_TEXT" I just left it as is was and didnt change anything.

However you can change it to "ENTRY_TAXID_NUMBER_TEXT" just make sure to define that variable in "includes/languages/english.php" and leave it blank (without any text), because I think this is the variable for the red colored * to let the customer know if it is a mandatory field (and in my example I did not make it mandatory)

Thanks.

24 Aug 2007, 10:11 PM
#11
rdhinman avatar

rdhinman

New Zenner

Join Date:
Sep 2005
Location:
Spencer, MA
Posts:
35
Plugin Contributions:
0

Re: Add a field into create account

thank you for the quick reply. I will do the alterations this weekend.

7 Sep 2007, 4:55 AM
#12
jbhansen avatar

jbhansen

New Zenner

Join Date:
Dec 2006
Posts:
19
Plugin Contributions:
0

Re: Add a field into create account

Thanks for the clear directions on getting this field added. It's exactly what we wanted ourselves!

This works great for new customers and for admins looking at customer records. However, we also needed to allow existing customers the ability to edit their tax id number (or add it if they've never done so).

Here are the steps we followed to allow an existing customer to edit his/her tax ID. Hopefully it's helpful as well.

1) In the file \includes\templates<YOUR TEMPLATE>\templates\tpl_account_edit_default.php (it wasn't there for us so we copy-pasted it from the template_default folder)

Right after:

<label class="inputLabel" for="fax"><?php echo ENTRY_FAX_NUMBER; ?></label>
<?php echo zen_draw_input_field('fax', $account->fields['customers_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
Inserted:

<label class="inputLabel" for="taxid"><?php echo 'Tax ID Number:'; ?></label>
<?php echo zen_draw_input_field('taxid', $account->fields['customers_taxid'], 'id="taxid"') . (zen_not_null(ENTRY_TAXID_TEXT) ? '<span class="alert">' . ENTRY_TAXID_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
**BY THE WAY: the variables ENTRY_TAXID_TEXT weren't in our english.php file, so we added them right after ENTRY_FAX_NUMBER_TEXT. As has been stated in a previous post, you could leave the TAXID out of it and just use the FAX_NUMBER there, but we wanted to be thorough even though it probably makes little difference.
2) In the file \includes\modules\pages\account_edit\header_php.php:
a) After:

$fax = zen_db_prepare_input($_POST['fax']);
Inserted:

$taxid = zen_db_prepare_input($_POST['taxid']);
b) After:

array('fieldName'=>'customers_fax', 'value'=>$fax, 'type'=>'string'),
Inserted:

array('fieldName'=>'customers_taxid', 'value'=>$taxid, 'type'=>'string'),
c) Within the array:

$account_query = "SELECT customers_gender, customers_firstname, customers_lastname,

customers_dob, customers_email_address, customers_telephone,

customers_fax, customers_email_format, customers_referral

FROM " . TABLE_CUSTOMERS . "

WHERE customers_id = :customersID";
Added customers_taxid, as follows:

$account_query = "SELECT customers_gender, customers_firstname, customers_lastname,

customers_dob, customers_email_address, customers_telephone,

customers_fax, customers_taxid, customers_email_format, customers_referral

FROM " . TABLE_CUSTOMERS . "

WHERE customers_id = :customersID";

That should do it. BTW, we created these instructions after we implemented the change, so hopefully we didn't overlook something.

jbhansen

7 Sep 2007, 11:10 PM
#13
blacklancer avatar

blacklancer

New Zenner

Join Date:
Aug 2007
Posts:
1
Plugin Contributions:
0

Re: Add a field into create account

thank you for this how to. I have one question though. I added 3 fields like this (Vehicle Year, Make, and Model) and I would like them to show up on the Invoice.

I tried adding them to Invoice.php, and when I pull up an invoice, I get an error.

I added the information at the top:

customers_state, customers_country, customers_telephone,
customers_year, customers_make, customers_model,
customers_email_address, customers_address_format_id, 

and i added it below the e-mail address:

<tr>
    <td class="main"><?php echo '<a href="mailto:' . $order->customer['email_address'] . '">' . $order->customer['email_address'] . '</a>'; ?></td>
</tr>
<tr>
    <td class="main"><?php echo $order->customer['customers_year']; ?> <?php echo $order->customer['customers_make']; ?> <?php echo $order->customer['customers_model']; ?></td>
</tr>

this is the error i get:

1054 Unknown column 'customers_year' in 'field list'

any ideas??

8 Sep 2007, 11:19 PM
#14
craigw avatar

craigw

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
0

Re: Add a field into create account

Thanks to xlr82quik for pioneering this mod. I've tidied up the instructions and made the modications a little more compliant and easier to maintain. You can do a file compare to see the changes if you like.

Procedure:

0. Backup your database using PHPMyAdmin, also backup the affected files before making each change.

1. Go to PHPMyAdmin and select your database from the pulldown.
2. On the left sidebar of PHPMyAdmin click on the table "customers"
3. On the right side of the screen you will see all the fields like customers_telephone, customers_fax and so-on... Now scroll below this and you should see a way to add a field, in mine I saw:

The "Add" text box should contain "1", in the field(s) section, select the "At end of table" radio button, leave everything else as it is and then click the "GO" button.

This sent me to another page to name my field and stuff so I named it "customers_taxid" (no quotation marks). Then I selected "VarChar" and a length of "32"(or whatever length in characters you want your new entry field), Collation = (it was blank and I left it blank), Attributed = (it was blank and I left it blank), Null = NULL

Then I clicked "SAVE"

4. I then saw my new field in the table it was on the bottom of all the other ones that were previously there.

5. Close PHPMyAdmin

6. Open file includes/modules/YOURTEMPLATE/create_account.php
(or if your template did not override this then simply use the one in modules folder)

7a. Now search for the following:

$fax = zen_db_prepare_input($_POST['fax']);

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

$taxid = zen_db_prepare_input($_POST['taxid']);

7b. Next search for:

'customers_fax' => $fax,

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

'customers_taxid' => $taxid,

8a. Now open file: includes/languages/YOURTEMPLATE/english.php
(or if your template did not override this then simply use the one in languages folder)

8b. Search for the following code:

define('TABLE_HEADING_PHONE_FAX_DETAILS', 'Additional Contact Details');

this is the heading for the section on the form that houses the telephone number and fax number inputs, I changed it to this:

define('TABLE_HEADING_PHONE_FAX_DETAILS', 'Additional Details');

this allowed my heading to say "Additional Information" instead of the original text of "Additional Contact Details" *

8c. Also add the following code:

define('ENTRY_TAXID_NUMBER', 'TAX ID:');

define('ENTRY_TAXID_NUMBER_TEXT', '');

to be tidy, this entry should be added to where all the other "define('ENTRY..." statements are.

9. Now open file: includes/templates/YOURTEMPLATE/templates/tpl_modules_create_account.php

9a. Now search for the following code:

<?php if (ACCOUNT_FAX_NUMBER == 'true') { ?> <br class="clearBoth" /> <label class="inputLabel" for="fax"><?php echo ENTRY_FAX_NUMBER; ?></label> <?php echo zen_draw_input_field('fax', $account->fields['customers_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?> <?php } ?>

DO NOT ERASE THE ABOVE CODE, ONLY PASTE THE NEW LINES OF CODE BELOW THE CODE ABOVE, here is the new code to paste under the code above:

<br class="clearBoth" /> <label class="inputLabel" for="taxid"><?php echo ENTRY_TAXID_NUMBER; ?></label> <?php echo zen_draw_input_field('taxid', $account->fields['customers_taxid'], 'id="taxid"') . (zen_not_null(ENTRY_TAXID_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_TAXID_NUMBER_TEXT . '</span>': ''); ?>

10. Now go to Admin/customers.php and edit this file.
(editing this file will allow you to see the taxid field when you edit customer information in the administrative section)

11. Search for:

$customers_fax = zen_db_prepare_input($_POST['customers_fax']);

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

$customers_taxid = zen_db_prepare_input($_POST['customers_taxid']);

11a. Now search for:

'customers_fax' => $customers_fax,

DO NOT ERASE THE ABOVE CODE. PUT THE NEW CODE DIRECTLY UNDER THE CODE ABOVE, HERE IS THE EXTRA LINE OF CODE:

'customers_taxid' => $customers_taxid,

11b. Now search for:

a.entry_country_id, c.customers_telephone, c.customers_fax,

REPLACE THIS CODE WITH THE FOLLOWING CODE BELOW:

a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_taxid,

(ALL I DID WAS ADD "c.customers_taxid," TO THE END OF THE EXISTING CODE.)

11c. Now search for:

<tr> <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td> <td class="main"> <?php if ($processed == true) { echo $cInfo->customers_fax . zen_draw_hidden_field('customers_fax'); } else { echo zen_draw_input_field('customers_fax', $cInfo->customers_fax, zen_set_field_length(TABLE_CUSTOMERS, 'customers_fax', 15)); } ?> </td> </tr>

DO NOT ERASE THIS CODE SIMPLY GO DIRECTLY UNDER THIS CODE AND ADD IN THE FOLLOWING CODE:

<tr> <td class="main"><?php echo ENTRY_TAXID_NUMBER; ?></td> <td class="main"> <?php if ($processed == true) { echo $cInfo->customers_taxid . zen_draw_hidden_field('customers_taxid'); } else { echo zen_draw_input_field('customers_taxid', $cInfo->customers_taxid, zen_set_field_length(TABLE_CUSTOMERS, 'customers_taxid', 15)); } ?> </td> </tr>
8 Sep 2007, 11:47 PM
#15
craigw avatar

craigw

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
0

Re: Add a field into create account

Thanks to jbhansen for pioneering it. I've also updated his instructions. (I didn't edit my above post in time to add this)

Here are the steps we followed to allow an existing customer to edit his/her tax ID. Hopefully it's helpful as well.

1) In the file \includes\templates<YOUR TEMPLATE>\templates\tpl_account_edit_default.php (it wasn't there for us so we copy-pasted it from the template_default folder)

Right after:
<label class="inputLabel" for="fax"><?php echo ENTRY_FAX_NUMBER; ?></label>

<?php echo zen_draw_input_field('fax', $account->fields['customers_fax'], 'id="fax"') . (zen_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?> <br class="clearBoth" />

Inserted:
<label class="inputLabel" for="taxid"><?php echo ENTRY_TAXID_NUMBER; ?></label>

<?php echo zen_draw_input_field('taxid', $account->fields['customers_taxid'], 'id="taxid"') . (zen_not_null(ENTRY_TAXID_NUMBER_TEXT) ? '<span class="alert">' . ENTRY_TAXID_NUMBER_TEXT . '</span>': ''); ?> <br class="clearBoth" />

2) In the file \includes\modules\pages\account_edit\header_php.php:

a) After:
$fax = zen_db_prepare_input($_POST['fax']);
Inserted:
$taxid = zen_db_prepare_input($_POST['taxid']);

b) After:
array('fieldName'=>'customers_fax', 'value'=>$fax, 'type'=>'string'),
Inserted:
array('fieldName'=>'customers_taxid', 'value'=>$taxid, 'type'=>'string'),

c) Within the array:
$account_query = "SELECT customers_gender, customers_firstname, customers_lastname,
customers_dob, customers_email_address, customers_telephone,
customers_fax, customers_email_format, customers_referral
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";

Added customers_taxid, as follows:
$account_query = "SELECT customers_gender, customers_firstname, customers_lastname,
customers_dob, customers_email_address, customers_telephone,
customers_fax, customers_taxid, customers_email_format, customers_referral
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";

16 Oct 2007, 5:46 AM
#16
kdtaylor avatar

kdtaylor

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: Add a field into create account

This is fantastic!! Thank you for sharing :)
Does anyone know how I can make this field 'required'?
Adding the errors if they do not fill it in , and the red required text beside the box?

Thanks
KT

18 Oct 2007, 10:33 AM
#17
beto_pu avatar

beto_pu

New Zenner

Join Date:
Apr 2007
Posts:
14
Plugin Contributions:
0

Re: Add a field into create account

kdtaylor it's very simple in " define('ENTRY_TAXID_NUMBER_TEXT', ''); " put an "" as the definition like this: "define('ENTRY_TAXID_NUMBER_TEXT', '');"

I hope I made myself clear as my English is a little rusty

19 Oct 2007, 4:38 AM
#18
kdtaylor avatar

kdtaylor

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: Add a field into create account

I have had a play and managed to get error messages working ...
Here is how I did it ....

Please note ... rather than 'taxid' I am using 'studentname' as our cart if for a school..

  1. /includes/languages/YOURTEMPLATE/english.php
    a. Find ' define('ENTRY_TELEPHONE_NUMBER_TEXT', '');'
    b. Under this entry insert
    //
    define('ENTRY_STUDENTNAME', 'Students Name:');
    define('ENTRY_STUDENTNAME_ERROR', 'Your childs name must contain a minimum of ' . ENTRY_FIRST_NAME_MIN_LENGTH . ' characters.');
    define('ENTRY_STUDENTNAME_TEXT', '
    ');
    //

  2. /includes/modules/pages/create_account/jscript_form_check.php
    a. Find ' check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>");'
    b. Under this entry insert
    <!-- STUDENT INFO HERE -->
    check_input("studentname", <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>, "<?php echo ENTRY_STUDENTNAME_ERROR; ?>");
    <!-- END -->

  3. /includes/modules/pages/account_edit/jscript_form_check.php
    a. Find ' check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>");'
    b. Under this entry insert

    <!-- STUDENT INFO HERE -->

    check_input("studentname", <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>, "<?php echo ENTRY_STUDENTNAME_ERROR; ?>");
    <!-- END -->

  4. /includes/template/YOURTEMPLATE/template/
    a. Update ENTRY_???_TEXT fields that you hade previously entered for taxid info

     <br class="clearBoth" />
     <label class="inputLabel" for="studentname"><?php echo 'Students Name:'; ?></label>
     <?php echo zen_draw_input_field('studentname', $account->fields['customers_studentname'], 'id="studentname"') . (zen_not_null(ENTRY_STUDENTNAME_TEXT) ? '<span class="alert">' . ENTRY_STUDENTNAME_TEXT . '</span>': ''); ?>
    
19 Oct 2007, 1:14 PM
#19
dizz avatar

dizz

Zen Follower

Join Date:
Oct 2006
Posts:
170
Plugin Contributions:
0

Re: Add a field into create account

Great post, thank you for taking the time to write the steps out - this is a great step-by-step for PHP novices & pros alike as you clearly identify each page that needs updating! Should be a sticky IMO...

24 Oct 2007, 3:23 PM
#20
seany avatar

seany

New Zenner

Join Date:
Oct 2007
Posts:
8
Plugin Contributions:
0

Re: Add a field into create account

:frusty:Tremendous advice contained within. May i please enquire as to how to take the new field a stage further ? My requirement is that instead a 'free-input field, i would like the customer to select an option from a dropdown menu - AND make it compulsory.
Any suggestions ? Thanks.