Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can I make "address" not a required field?


Guest

Recommended Posts

In create_account.php, I'd like to make the customer's address and some other information not required fields. The products being sold on this web site are all virtual, so this info is not required. Where in the code do I find this?

Link to comment
Share on other sites

It looks to me like you could add the phrase that applies to all the optional fiels where it checks whether that info is turned on or off, some like if blahblah='true', and before that actually define that variable as false, it would exclude that bit of data from being collected. There's no guarantee that you wouldn't get messed up farther down the road, if there are other files, like the checkout ones, that are expecting that info to be in the database.You might be able to set the minimum values for those fields to zero, and display a note saying the info is in fact optional on the create account page. Jeremy

Link to comment
Share on other sites

After looking more at create_account, maybe the code I'm looking for is in a different file. Here's the line to create the input box for telephone number (a required field):

<td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
               <td class="main"><?php echo tep_draw_input_field('telephone') . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>
             

 

This is the line that creates the box for "fax number" (a non-required field):

<td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>
               <td class="main"><?php echo tep_draw_input_field('fax') . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?></td>
             

 

I don't see any difference in there. Somewhere else there must be a variable that's set for these fields. Any idea of where to find it?

Link to comment
Share on other sites

I don't know, I was thinking of the code like this for suburb:

 

Near the top it checks to see if it will be making an entry for suburb:

 if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);

 

Then later it checks again to see if it needs to draw the box:

<?php
 if (ACCOUNT_SUBURB == 'true') {
?>
             <tr>
               <td class="main"><?php echo ENTRY_SUBURB; ?></td>
               <td class="main"><?php echo tep_draw_input_field('suburb') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>
             </tr>
<?php

 

I was thinking you could add these checks into the address lines too, after first specifically defining these variables as false. If you wanted to do this right, rather than just jerry rig it like my suggestion, you'd need to find the code that makes the particular fields optional, and the controls that are in the admin panel, and replicate that for these fields of the database, then you'd define the truth or falseness from admin. Then test it to see that other files aren't relying on the information to necessarily be there, like checkout.php Jeremy

Link to comment
Share on other sites

You're right, it would. Well then, maybe you could modify the minimum values to zero in admin. You will probably have to change the settings in the address book table of the database so those entries could be null.

 

That red asterisk is associated with span class="inputRequirement" because here's the source that comes up with what you see for phone and fax:

 ?<td class="main">Telephone Number:</td>
? ? ? ? ? ? ? ?<td class="main"><input type="text" name="telephone"> <span class="inputRequirement">*</span></td>
? ? ? ? ? ? ?</tr>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main">Fax Number:</td>
? ? ? ? ? ? ? ?<td class="main"><input type="text" name="fax"> </td>
? ? ? ? ? ? ?</tr>

 

I'd look for something in the classes folder maybe for that variable. Jeremy

Link to comment
Share on other sites

Hey Luc's Music...

 

I'm guessing all you really should need to do is 1 thing.. or actaully maybe 2 things:

 

1 - change the mysql field to null instead of notnull.. that should work

2 - look for the code that sez "if varx = !"

 

as far as I see it the code actaully allows you to submit the form.. then for those fields that are set as NOTNULL in the MySQL database it returns the error statement beside it :D so you shouldn't have to do 2 at all!

 

Hope this helps!

Link to comment
Share on other sites

Working on this one right now myself. I believe determining whether a field is required or not happens in form validation at catalog/admin/customer.php. Still going through the code myself to sort it out.

 

[EDIT: My best guess is that it has something to do with ($error == true) vs. ($processed == true). Need to confirm though.]

Link to comment
Share on other sites

I've managed to make it not a required field, but I'm not entirely sure what did it. I set the minimum values for all of those fields to 0, but it still popped up a window that said "X must be at least 0 characters long." I even tried setting that to -1, but the window still told me that it must be at least -1 characters long. I went into the database and changed the fields to "null" from "not null" and that still didn't quite do it. I went into create_account.php and commented out the entire section where it checks to see:

if ($address < ADDRESS_STRING_MIN_LENGTH){
$error = true;
}

or whatever it is.

 

So now, I can create an account without putting in address and the other things that I don't need. I still have a red * next to those fields that I can't get rid of.

 

HTH.

Link to comment
Share on other sites

Hmm? I'm tryiing to make Date of Birth optional. I might also like to add additional optional fields in the future, but would be happy with the DOB for now. May be related, but I'd also like to add an Address line 2 and 3. I've had some international customers in the past that would definitely need three lines.

 

If you find any more leads, please post. Thanks!

Link to comment
Share on other sites

Yeah, I know, that's how I have it set now, but I would like to keep DOB and make it optional. I'd also like to add a few more optionals that would help me learn more about my customers.

 

Any ideas.

Link to comment
Share on other sites

I've managed to make it not a required field, but I'm not entirely sure what did it. I set the minimum values for all of those fields to 0, but it still popped up a window that said "X must be at least 0 characters long." I even tried setting that to -1, but the window still told me that it must be at least -1 characters long. I went into the database and changed the fields to "null" from "not null" and that still didn't quite do it. I went into create_account.php and commented out the entire section where it checks to see:
if ($address < ADDRESS_STRING_MIN_LENGTH){
$error = true;
}

or whatever it is.

 

So now, I can create an account without putting in address and the other things that I don't need. I still have a red * next to those fields that I can't get rid of.

 

HTH.

Rather than setting the minimum values to 0 or -1 or whatever, just make them blank.

 

(I'm working on the same problem...)

Link to comment
Share on other sites

In Includes > Languages > english.php

 

Scroll down to find

 

define('ENTRY_COMPANY', 'Company Name:');
define('ENTRY_COMPANY_ERROR', '');
define('ENTRY_COMPANY_TEXT', '');
define('ENTRY_GENDER', 'Gender:');
define('ENTRY_GENDER_ERROR', 'Please select your Gender.');
define('ENTRY_GENDER_TEXT', '*');
define('ENTRY_FIRST_NAME', 'First Name:');
define('ENTRY_FIRST_NAME_ERROR', 'Your First Name must contain a minimum of ' . ENTRY_FIRST_NAME_MIN_LENGTH . ' characters.');
define('ENTRY_FIRST_NAME_TEXT', '*');

 

(This is only the beginning of the section you need to edit).

 

In there, you can see some entries with a * beside them. ENTRY_GENDER_TEXT, for example. Just take out the * you don't want, but leave in the quotation marks.

Link to comment
Share on other sites

In create_account.php, I'd like to make the customer's address and some other information not required fields. The products being sold on this web site are all virtual, so this info is not required. Where in the code do I find this?

I'm not sure about those being in the english.php file, but the file in the catalog/includes/modules/address_book_details.php has the main one's your looking for, I think.

Best Regards

Link to comment
Share on other sites

to get rid of the * simply look for

 

(tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>

 

ENTRY_GENDER_TEXT will change dependent on the field you're looking at. This line of code is what calls the * and the fill-in-this-line when there's an omitted line of required data.

Link to comment
Share on other sites

Yep, I found that in includes/languages/english.php. I don't know why I didn't think of that before. Now those fields are optional, and only the required fields have a *. That part of the project is complete! Thanks to all who helped.

Link to comment
Share on other sites

Yeah, I know, that's how I have it set now, but I would like to keep DOB and make it optional.  I'd also like to add a few more optionals that would help me learn more about my customers.

 

Any ideas.

JABeven, this is how I make my DOB and other fields optional.

 

In catalog/create_account.php, I comment out the following

 

/*

      if (ACCOUNT_DOB == 'true') {

      if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) {

        $error = true;

 

        $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);

      }

    }

*/

 

Then comment out the DOB portion to remove it from the form.

 

<? /*

<?php

  if (ACCOUNT_DOB == 'true') {

?>

              <tr>

                <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>

                <td class="main"><?php echo tep_draw_input_field('dob') . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>

              </tr>

<?php

  }

?>

*/ ?>

 

Then in catalog/account_edit.php, comment out this.

 

/*

    if (ACCOUNT_DOB == 'true') {

      if (!checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4))) {

        $error = true;

 

        $messageStack->add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR);

      }

    }

*/

 

In catalog/includes/form_check.js.php, comment out this.

 

// <?php if (ACCOUNT_DOB == 'true') echo '  check_input("dob", ' . ENTRY_DOB_MIN_LENGTH . ', "' . ENTRY_DATE_OF_BIRTH_ERROR . '");' . "\n"; ?>

 

In catalog/includes/languages/english.php

 

Change this line:
define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 05/21/1970)');

to:

define('ENTRY_DATE_OF_BIRTH_TEXT', '(eg. 05/21/1970)');

 

That's it! Do the same to any field you want optional. Hope this helps. ;)

Link to comment
Share on other sites

  • 1 month later...

What I need to do is just the opposite. I need to add a phone number field to the pages where you can select or add new addresses to the address book. I'm using the primary customer address as the gift sender's address, and the other addresses in the address book as the gift recipient's address, and I need a phone number field for the recipient. This phone number is separate from the customer's phone number. I've already added an entry_telephone field to the address book table in the database, but I'm stumped as to how to get the cart to draw the input box, and which files I need to edit (and what code, etc. to change or add). Any experts in a helpful mood out there willing to help a desperate newbie? :(

 

Thanks,

Joan

Link to comment
Share on other sites

I'm not much of an expert, but here would be my solution.

 

Open the file where a customer enters his own address when creating an account. That would probably be create_account.php but I'm not sure - go through the process of creating an account, find that page and see what the URL is in the title bar.

 

Open that file in your php editor.

 

Find the part of code that creates the text input box, highlight and copy. Make sure you get all of the <tr><td></tr></td> that goes with it. These are important for making things line up correctly, they are HTML table commands.

 

Open the file address_book.php ad insert that code where you want it to appear.

 

Edit the variables to match what you're using.

 

Edit the database query in address_book.php to include the phone number.

 

Run the file, get a parse error.

 

Go back and find the stupid typo that you made.

 

Your results may vary...like I said, this would be my solution. I can't ever seem to edit something without forgetting a ; or a ' somewhere...hello, parse error!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...