How to write error trapping code on create account?
I know that this is a topic that is probably too hard for a beginner, but none the less I need to figure out a way to get it done. I have added a new field for customers to enter their tax id number (which we require as a wholesaler) to sign up for an account. Back in the days of ZC 1.2.x there was a great mod called taxid 1.0 that worked perfect, unfortunately that code does not work in 1.3.x as some of the files have been combined or moved. Anyway here is part of the code from another post that I have tried, the post is: Add a field into create account and this is the last half of the post
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>': ''); ?>
Now my forms and all appear fine and can be submitted without any errors. However, when you exclude the tax id altogether or do not use the required amount of characters, it does not error out letting the customer know the form is not filled out correctly and which field caused the error.
I have tried to figure it out and duplicate the code for the telephone number, or address field and cannot seem to figure it out as multiple files make up this function.
Can someone please help or if you have a taxid field working on your site please post the working code.
And for the developers, for future releases can you please code into the base code a taxid function that can be turned on and off at will, that will be a BIG help to wholesalers.
tia...
0be1
"Give me one hundred preachers who fear nothing but sin and desire nothing but God, and I care not whether they be clergymen or laymen, they alone will shake the gates of Hell and set up the kingdom of Heaven upon Earth." - John Wesley