Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding fields to Customer Details


Guest

Recommended Posts

Hi there,

 

I am trying to reverse-engineer the Customer Details to add 3 new fields: Height, Weight, and Waist-size. I am preparing to do this now, and am wondering if anyone can think of any other files I have to change besides:

 

catalog/create_account.php

catalog/account_edit.php

catalog/ includes/languages/english/create_account.php

 

 

Do I have to change anything in Admin?

Link to comment
Share on other sites

Okay, for example, with HEIGHT.

 

I added a database table called customers_height.

 

I added the following defines in /cat/incl/lang/english.php:

 

define('ENTRY_CUSTOMER_HEIGHT','Your Height');
define('ENTRY_CUSTOMER_HEIGHT_TEXT', '* (in cms)');

 

In /includes/create_account.php I added the following below the customers email (around line 476):

 

<tr> 
                     <td class="main"><?php echo ENTRY_CUSTOMER_HEIGHT; ?></td>
                     <td class="main"><?php echo tep_draw_input_field('height') . ' ' . (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="inputRequirement">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': ''); ?></td>
                   </tr>

 

Okay, so that should get the filed to appear and have the right text next to it.

 

I also popped this in around line 42:

   $height = tep_db_prepare_input($HTTP_POST_VARS['height']);

 

Height is not a required element.

 

I also did all this for the account_edit.php as well.

 

Here is the problem: It looks fine but it isn't writing to the database. I made a new account, entered a random height, but it didn't remmeber it when I tried to adjust it in account_edit.php.

 

What am I missing?

Link to comment
Share on other sites

2 more quick questions:

 

1) Why is there no colon appearing after my <td class="main"><?php echo ENTRY_CUSTOMER_HEIGHT; ?></td>? I can't figure out why it appears on all the other ones but mine...

 

2) How can I shorten up the textfield length? I don't think people will be putting in more than 3 characters for each of the sizes.

 

Cheers,

 

R

Link to comment
Share on other sites

Perfect. Thanks a lot Peter. I got it writing to the DB, editable in the user account, and visible and editable in the Admin. Took a lot of tweaking and detective work, but it is all go now.

 

There still remains the 2 questions above, and I have 2 new questions. In the Admin we can put a Maxlength on the text field. See admin/customers.php:

 

<?php
 if ($processed == true) {
   echo $cInfo->customers_height . tep_draw_hidden_field('customers_height');
 } else {
   echo tep_draw_input_field('customers_height', $cInfo->customers_height, 'maxlength="3"');
 }
?>

 

I am trying to do the same thing on the customers side, but since I am a php noob, the difference between the syntax makes them uncomparable and frightens me. From create_account.php:

<?php echo tep_draw_input_field('height') . ' ' . (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="caption">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': ''); ?>

 

Where would I stick in the 'maxlength="3"'?

 

Now the other thing is I am trying to put the ENTRY_CUSTOMER_HEIGHT_TEXT from create_account.php into the admin/customers.php. Where in customers.php would I put this:

 

. (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="caption">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': '')

 

Once this is all done, I might write up a tutorial in stick it in Tips & Tricks.

Link to comment
Share on other sites

Hi,

 

I haven't used or know much about the tep_draw_input_field() function, but it seems that the code where you have got it to use the 'max length' is the third parameter, so try this:

 

<?php echo tep_draw_input_field('height',,'maxlength="3"') . ' ' . (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="caption">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': ''); ?>

 

That's a wild guess though. :D

 

Peter

Link to comment
Share on other sites

Good guess, but that just broke it.

 

Previously I had tried putting it in the second position, but that just stuck maxlength=3 inside the field!

 

Any others?

Link to comment
Share on other sites

Hi,

 

The function is defined in /catalog/includes/functions/html_output.php

 

 159  // Output a form input field
160    function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
161      $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
162  
163      if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
164        $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
165      } elseif (tep_not_null($value)) {
166        $field .= ' value="' . tep_output_string($value) . '"';
167      }
168  
169      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
170  
171      $field .= '>';
172  
173      return $field;
174    }

 

.. and I don't think it will like the second parameter parsed as I earlier suggested. Try this ......

 

<?php echo tep_draw_input_field('height','56','maxlength="3"') . ' ' . (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="caption">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': ''); ?>

 

Peter

Link to comment
Share on other sites

That's the ticket Peter!!! Thanks very much!!

 

Now to shorten the length of the text box and add that colon. Oh yeah, and get centimeters to display in the Admin.

Link to comment
Share on other sites

Here is my length solution:

<?php echo tep_draw_input_field('height', $account ['customers_height'],'maxlength="3"' . 'style="width: 30"') . ' ' . (tep_not_null(ENTRY_CUSTOMER_HEIGHT_TEXT) ? '<span class="caption">' . ENTRY_CUSTOMER_HEIGHT_TEXT . '</span>': ''); ?>

 

It makes the box 30px wide, just enough for about 4 characters. Perfect. If there is any better way, please let me know.

 

Cheers!

 

R

Link to comment
Share on other sites

Hi,

 

Just PM a moderator.

 

http://www.oscommerce.com/forums/index.php?act...y=name&st=0&b=1

 

I notice that these forums go "off the air" once a day, for about 5 mins, and no doubt you were like me, I had a new post just finished, pressed the button to post, and had to wait until it was all going again.

 

I try a ping, no problems, but a 'dig' on the forums , shows up that the HTTP side of things is not available. Maybe it's when they do backups or some maintenance ??

 

Peter

Link to comment
Share on other sites

  • 1 month later...

Hi,

This is wonderful! I thank you for posting this, it exactly what we need for our site.

Have a few questions though

 

1. With this ->

Okay, for example, with HEIGHT.

 

I added a database table called customers_height.

 

I added the following defines in /cat/incl/lang/english.php:

 

CODE

 

define('ENTRY_CUSTOMER_HEIGHT','Your Height');

define('ENTRY_CUSTOMER_HEIGHT_TEXT', '* (in cms)');

 

Is this and other fields that we might want entered at about line 163 of /cat/incl/lang/english.php:

define('ENTRY_COMPANY', 'Company Name:');

and line 227 at the end of all entry definitions. Or can it be entered any where?

 

2. And with this ->

I also popped this in around line 42:

CODE

 

  $height = tep_db_prepare_input($HTTP_POST_VARS['height']);

 

I assume that if I had three other fields, I would just enter each one after the other around this area. Am i correct?

 

3.

I also did all this for the account_edit.php as well.

Do you mean the codes added to /includes/create_account.php was also added to account_edit.php

 

I guess those are my questions for now. Any help would be great.

 

Your solution is very good!

Link to comment
Share on other sites

Hi,

 

Or can it be entered any where?

 

Yes, it can be entered anywhere, but do try and keep it in some sort of order, so add it after this line:

 

define('ENTRY_COMPANY_TEXT', '');

 

and don't forget to add the same line , for the other languages.

 

I assume that if I had three other fields, I would just enter each one after the other around this area. Am i correct?

 

Yes, add some comments what the mods do,etc, it will help.

 

Peter

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...