Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

My Account Information - Change the required fields


Guest

Recommended Posts

Hi !

 

I am searching for a possiblity to change the required field in the "My Account" Section. Where can I define which entry is required and which not ?

 

thanks a lot :D

 

thomas

Link to comment
Share on other sites

Here you are:

 

catalog/includes/application_top.php

 

Look for these lines:

 

// Control what fields of the customer table are used

 define('ACCOUNT_GENDER', 'true');

 define('ACCOUNT_DOB', 'true');

 define('ACCOUNT_COMPANY', 'false');

 define('ACCOUNT_SUBURB', 'true');

 define('ACCOUNT_STATE', 'true');

 

And please start using the search function BEFORE posting a question. This question has been answered a multi-dozen times.

You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist.

Link to comment
Share on other sites

Dammit. I knew I answered something similar before.

 

http://www.oscommerce.com/forums/viewtopic.php...ighlight=#68268

 

Please help yourself by using the search function. We are here to help you, but please also show a little respect to the community by searching BEFOPRE posting.

You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist.

Link to comment
Share on other sites

I don?t want to know how to switch on/off an input field. I want to know how to make a field required or not. So for example: I like to have the birthday field, so if someone like to tell me his date, he can do that. but it should not be required, because he can buy something even if he don?t like to tell it.

 

Thanks

Thomas

 

-> If you read the question carefully, and have little respect to the community-member who just request something when he don?t find anything about that topic in the community, you can save your time :wink:

Link to comment
Share on other sites

-> If you read the question carefully, and have little respect to the community-member who just request something when he don?t find anything about that topic in the community, you can save your time  :wink:

 

Actually, he did answer your question. You just weren't clear in your first question. Now that you have explained yourself, an different answer can be made.

 

Open up /catalog/includes/form_check.js.php and look at line 68.

 

Patrick

Patrick

Link to comment
Share on other sites

  • 3 months later...

I think this question has been answered badly all over this forum and I believe the problem is due to misunderstanding. Let's see if I can clear it up since it took me a while to figure out what you all going around in circles about on several threads.

 

Let us use the Telephone Number as an example, since that was one thing I wanted to make optional. I modified includes/modules/account_details.php from

 

<?php

 if ($is_read_only) {

   echo $account['customers_telephone'];

 } elseif ($error) {

   if ($entry_telephone_error) {

     echo tep_draw_input_field('telephone') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;

   } else {

     echo $telephone . tep_draw_hidden_field('telephone');

   }

 } else {

   echo tep_draw_input_field('telephone', $account['customers_telephone']) . ' ' . ENTRY_TELEPHONE_NUMBER_TEXT;

 }

?>

 

to

 

<?php

 if ($is_read_only) {

   echo $account['customers_telephone'];

 } elseif ($processed) {

   echo $telephone . tep_draw_hidden_field('telephone');

 } else {

   echo tep_draw_input_field('telephone', $account['customers_telephone']) . ' ' . ENTRY_TELEPHONE_NUMBER_TEXT;

 }

?>

 

I don't know if this is right or wrong, but it's what I did and it worked. Then I opened includes/form_check.js.php and commented

 

 if (document.account_edit.elements['telephone'].type != "hidden") {

  if (telephone == '' || telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {

     error_message = error_message + "<?php echo JS_TELEPHONE; ?>";

     error = 1;

   }

 }

 

That seemed to do what I wanted it to do. Mind you, I know little to nothing about PHP, but with a little determination and a whole lot of commenting, uploading, checking, uncommenting, and repeating, I finally figured it out on my own since it wasn't really spelled out anywhere. I hope this helps everyone that was as lost as myself.

Link to comment
Share on other sites

RavenFae is on the right track in making telephone optional.

 

Leave the code in includes/modules/account_details.php as it was originally (switch it back)

 

You've correctly removed the client-side (JavaScript) check for the telephone field in includes/form_check.js.php, but it will fail on the server-side processing in

 

account_edit_process.php

create_account_process.php

 

Go to those files and comment out the areas

  if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

   $error = true;

   $entry_telephone_error = true;

 } else {

   $entry_telephone_error = false;

 }

 

(I guess setting telephone number minimum length to in your admin area would do the same thing as this if you don't want to get into the code. For other fields like postal code you will need to dig in here though, so get familar with these *_process.php files)

 

 

Kyle

 

P.S. Think carefully before you make telephone optional - it is very useful to have a secondary (and more reliable) way to contact customers.

Link to comment
Share on other sites

P.S. Think carefully before you make telephone optional - it is very useful to have a secondary (and more reliable) way to contact customers.

 

Seeing that I am not using osCommerce for a store (at least not for this particular project), I have no need for Addresses or Phone Numbers. I use City, State/Province, and Zip/Post Code sometimes, just for tracking. What I really want to do is simply remove that information, but I was not sure if doing that, I would just cause more issues.

Link to comment
Share on other sites

I'm getting the following error after doing as you suggested...

 

Parse error: parse error in /home/www/books.traeonna.com/html/catalog/create_account_process.php on line 353

Link to comment
Share on other sites

:idea: TO REVIEW

 

EXAMPLE TO MAKE TELEPHONE FIELD OPTIONAL

 

File: includes/form_check.js.php

Comment:

 

if (document.account_edit.elements['telephone'].type != "hidden") { 

  if (telephone == '' || telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) { 

     error_message = error_message + "<?php echo JS_TELEPHONE; ?>"; 

     error = 1; 

   } 

 }

 

File: includes/modules/account_edit_process.php

Comment:

 

if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { 

   $error = true; 

   $entry_telephone_error = true; 

 } else { 

   $entry_telephone_error = false; 

 }

 

File: includes/languages/english.php

Comment or Modify From:

 

define('ENTRY_TELEPHONE_NUMBER_TEXT', ' <small><font color="#AABBDD">required</font></small>');

 

Add or Modify To:

 

define('ENTRY_TELEPHONE_NUMBER_TEXT', ' <small><font color="#AABBDD">optional</font></small>');

 

I think that's all I did. Now, my next feat...getting them not to show up at all! Fun, fun, fun!

Link to comment
Share on other sites

File: includes/modules/account_edit_process.php

 

Oops! This should just be account_edit_process.php. Don't know what crack I was smoking... :?

Link to comment
Share on other sites

I'm just on a roll today. For those interested, in knowing how to make the fields not show up on the "My Account Information" screen once you have successfully made them "optional," simply comment out the HTML for that field. In the example I gave earlier, I commented the following in includes/account_details.php (I wanted both Telephone AND Fax to not show, Fax was already "optional"):

 

<!-- MOD 01.26.03 MOD CONTACT BEGIN<td class="formAreaTitle"><br>< ?php echo CATEGORY_CONTACT; ?></td>

 </tr>

 <tr>

   <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

     <tr>

       <td class="main"><table border="0" cellspacing="0" cellpadding="2">

         <tr>

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

           <td class="main"> 

< ?php

 if ($is_read_only) {

   echo $account['customers_telephone'];

 } elseif ($error) {

   if ($entry_telephone_error) {

     echo tep_draw_input_field('telephone') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;

   } else {

     echo $telephone . tep_draw_hidden_field('telephone');

   }

 } else {

   echo tep_draw_input_field('telephone', $account['customers_telephone']) . ' ' . ENTRY_TELEPHONE_NUMBER_TEXT;

 }

?></td>

         </tr>

         <tr>

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

           <td class="main"> 

< ?php

 if ($is_read_only) {

   echo $account['customers_fax'];

 } elseif ($processed) {

   echo $fax . tep_draw_hidden_field('fax');

 } else {

   echo tep_draw_input_field('fax', $account['customers_fax']) . ' ' . ENTRY_FAX_NUMBER_TEXT;

 }

?></td>

         </tr>

       </table></td>

     </tr>

   </table></td> MOD 01.26.03 CONTACT END -->

 

I leave myself a lot of notes and such because I'm not all that talented at reading lines of code at a time. Dyslexic's nightmare, let me tell you. I didn't know how to "properly" comment PHP within HTML, so I just put a space after the < and before the ?.

Link to comment
Share on other sites

BTW, big thanks to specialk Kyle Richardson :D for giving me the last piece to the puzzle. I couldn't have done all of this without you and the rest who have posted bits and pieces on this topic. Hopefully I've helped clear it up a bit with my follow ups on my progress :idea: and it will help others in the future. :wink:

Link to comment
Share on other sites

:idea: I have successfully removed the Address, Post Code/Zip, and Contact Information (Telephone & Fax) from the ?My Account Information? page. I have not had any issues signing up for an account. Since I am using all the other fields, I have not tried them yet, but I am assuming they will become optional or remove as easily as the others.

Link to comment
Share on other sites

Hey specialk Kyle Richardson , have any ideas on how to now to alter the admin area so it matches the catalog? If you try to edit someone's information, errors all over the place. :x

Link to comment
Share on other sites

  • 3 weeks later...

also, the changes you make to account_edit_process.php you need to make to create_account_process.php so that new customers don't get a reuired error on fields u don't want to be required.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...