Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding Custom Fields to Customer Details


Guest

Recommended Posts

  • 4 months later...
  • Replies 84
  • Created
  • Last Reply

Please can someone help me with this problem i am having, i think i have been asking for help on the forum on the following matter for quite a while now and it seems to be beating me as i have tried so many things.

 

I can see how the code at the beginning of this topic works perfectly but instead of having a text field i would like a drop down menu.

 

I will be having prescriptions for optical lenses on my site so i want a range of -8.00 all the way through to +8.00 or so. How would i call up a list of these values where the blank text field would be. Please help!

 

Thankyou.

Link to comment
Share on other sites

  • 5 months later...

I have added 2 new fields and nearly everything works fine. The registration works correctly and the data is written in the database. But there is one thing wrong in the customers.php. I have managed to geht the fields into this file too, but the data from the database is not showing in the administration. Here is the code (BLZ and BRANCH are the new fields)

 

	  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
	<td class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>
  </tr>
  <tr>
	<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
	  <tr>
		<td class="main"><?php echo ENTRY_BLZ; ?></td>
		<td class="main">
<?php
if ($error == true) {
  if ($entry_blz_error == true) {
	echo tep_draw_input_field('entry_blz', $cInfo->entry_blz, 'maxlength="32"') . ' ' . ENTRY_BLZ_ERROR;
  } else {
	echo $cInfo->entry_blz . tep_draw_hidden_field('entry_blz');
  }
} else {
  echo tep_draw_input_field('entry_blz', $cInfo->entry_blz, 'maxlength="32"');
}
?></td>
	  </tr>
						  <tr>
		<td class="main"><?php echo ENTRY_COMPANY; ?></td>
		<td class="main">
<?php
if ($error == true) {
  if ($entry_company_error == true) {
	echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"') . ' ' . ENTRY_COMPANY_ERROR;
  } else {
	echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');
  }
} else {
  echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"');
}
?></td>
	  </tr>
				<tr>
		<td class="main"><?php echo ENTRY_BRANCH; ?></td>
		<td class="main">
<?php
if ($error == true) {
  if ($entry_branch_error == true) {
	echo tep_draw_input_field('entry_branch', $cInfo->entry_branch, 'maxlength="32"') . ' ' . ENTRY_BRANCH_ERROR;
  } else {
	echo $cInfo->entry_branch . tep_draw_hidden_field('entry_branch');
  }
} else {
  echo tep_draw_input_field('entry_branch', $cInfo->entry_branch, 'maxlength="32"');
}
?></td>
	  </tr>	  

	</table></td>
  </tr>

 

Furtheron I insertet the following:

 

		$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
	$customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);
	$customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);
	$customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
	$customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
	$customers_blz = tep_db_prepare_input($HTTP_POST_VARS['customers_blz']);
	$customers_branch = tep_db_prepare_input($HTTP_POST_VARS['customers_branch']);
	$customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);
	$customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);

 

		$sql_data_array = array('customers_firstname' => $customers_firstname,
							'customers_lastname' => $customers_lastname,
							'customers_email_address' => $customers_email_address,
							'customers_telephone' => $customers_telephone,
							'customers_blz' => $customers_blz,
							'customers_branch' => $customers_branch,
							'customers_fax' => $customers_fax,
							'customers_newsletter' => $customers_newsletter);

 

		$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_blz, c.customers_branch, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");

 

Thanks in advance for your help!

Link to comment
Share on other sites

  • 4 months later...

After nearly a year i have returned to this thread, seems to be inactive for the past 6 months.

 

Can anyone, with the same step by step accuracy as the first initial tutorial, please explain how to request the data from the extra fields and put them in the invoice and packing slip, order email etc, basically anything that is sent through with the order on it, needs to have this information.

 

And also how to have a drop down menu instead of a text input field.

 

 

I hope someone can help, just to add extra details to everything sent through from the store, and changing the text input fields to drop down menus.

 

Tim.

Link to comment
Share on other sites

  • 2 months later...

Hi there, for me this contribution has been a lifesaver as I'd been looking to add a number of fields to the customer account for some time however I still can't get the additional information to show in the packingslip or invoice.

 

I've tried all manner of things and even gone as far as trying to duplicate the new fields in the ORDER table in the db as well as in the CUSTOMER table (but this simply won't write from the checkout_process.php file).

 

Is there anyway I can do a cross table query (matching customer_id in the customer table and orders table of the db) to pick up the information and present it in the invoice?

 

If anyone can help with getting the new data into this file it woudl be appreciated.

 

Thanks

Link to comment
Share on other sites

After nearly a year i have returned to this thread, seems to be inactive for the past 6 months.

 

Can anyone, with the same step by step accuracy as the first initial tutorial, please explain how to request the data from the extra fields and put them in the invoice and packing slip, order email etc, basically anything that is sent through with the order on it, needs to have this information.

 

And also how to have a drop down menu instead of a text input field.

 

 

I hope someone can help, just to add extra details to everything sent through from the store, and changing the text input fields to drop down menus.

 

Tim.

 

Hi Tim

 

I don't know if you've found a solution yet but I managed to get a series of drop downs to work by replacing the input field code:

 

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

 

with the following:

 

<?php //Rta drop-down
 $Rta_array = array();
$Rta_array[0] = array('id' => '0', 'text' => 'Please Select');
$Rta_array[1] = array('id' => '-900', 'text' => '-900');
$Rta_array[2] = array('id' => '-800', 'text' => '-800');
?>
<td class="main" width="20%" align="center"><?php echo tep_draw_form('Rta', tep_href_link('links.php', 'action=catsel'), 'get').'' . 
tep_draw_pull_down_menu('Rta', $Rta_array, $account ['customers_Rta']); ?></td>

 

Rather than use a database query to extract the dd options I've hard coded the list content as I found this easier. The initial code stipulates the data for the dd and the <td> onwards presents the fields in the page.

 

This seems to work OK for me in conjunction with the rest of the instructions at the beginning of this thread.

Link to comment
Share on other sites

  • 1 month later...

With regards to adding information from custom fields into other things (like the confirmation e-mail or the confirmation page), I also had this problem and found a quick/dirty solution. I'm not a PHP or database expert by any means, so there are likely more efficient means to do this, but:

 

1. go to catalog/includes/languages/english/checkout_process.php and add the text that you want to appear in the e-mail to preface your custom field, you can add this anywhere within the code, like:

 

define('EMAIL_CAMPUS_ADDRESS', 'Campus Address:');

 

that will insert the words "Campus Address" into the confirmation e-mail when I called EMAIL_CAMPUS_ADDRESS. You can add whatever you want.

 

2. go to catalog/includes/checkout_process.php. The new database entry that I created via the first post in this tutorial is called customers_campus_address. To get information from the customers part of the database I selectively copied code that I found in other files that call the database. (This might be duplicitous because there already appears to be code to do this in checkout_process - but it worked for me so others are free to suggest better solutions). customers_campus_address is my new database entry and variable so replace that with yours in the same manner as the tutorial in this post. I put my variable as the last entry in these examples where I had to put it in. Find:

 

// load the before_process function from the payment modules
 $payment_modules->before_process();

 

and, after it, insert:

 

       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
       $customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);
       $customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);
       $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
       $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
       $customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);
       $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);
       $customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);
       $customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);
       $default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);
       $entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);
       $entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);
       $entry_postcode = tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']);
       $entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);
       $entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);
       $entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);
       $entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);
$customers_campus_address = tep_db_prepare_input($HTTP_POST_VARS['customers_campus_address']);



       $sql_data_array = array('customers_firstname' => $customers_firstname,
                               'customers_lastname' => $customers_lastname,
                               'customers_email_address' => $customers_email_address,
                               'customers_telephone' => $customers_telephone,
                               'customers_fax' => $customers_fax,
                               'customers_newsletter' => $customers_newsletter,
                               'customers_campus_address' => $customers_campus_address,);

       $sql_data_array = array('entry_firstname' => $customers_firstname,
                               'entry_lastname' => $customers_lastname,
                               'entry_street_address' => $entry_street_address,
                               'entry_postcode' => $entry_postcode,
                               'entry_city' => $entry_city,
                               'entry_country_id' => $entry_country_id);


 $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_delivery, customers_telephone, customers_fax, customers_campus_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
 $account = tep_db_fetch_array($account_query);

 

remember wherever I put customers_campus_address just replace that with your variable(s).

 

 

3. to actually display what you have, again in the catalog/includes/checkout_process.php file go down to

 

// lets start with the email confirmation
 $email_order = STORE_NAME . "\n" . 

 

and, wherever you'd like to position the information that you want to display in the e-mail, call the variable by calling, in my case, $account['customers_campus_address'], so, for example

 

 $email_order = STORE_NAME . "\n" . 
                EMAIL_SEPARATOR . "\n" . 
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n" .
                EMAIL_CAMPUS_ADDRESS . ' ' . $account['customers_campus_address'] . "\n\n";

 

will print the text that I put into "EMAIL_CAMPUS_ADDRESS" in catalog/includes/languages/english/checkout_process.php and display the information in my database entry (customers_campus_address) right below the "more detailed invoice." Replace customers_campus_address with whatever variable you have, save and upload the 2 files, and you should be good. You could also access other variables from that large list (just call whatever other variables you inserted in step 2) in the same manner. You can follow the code further in this section of the file to get a look at where information is displayed in the e-mail and edit/insert accordingly. The "\n" will add an extra space at the end of the line, make sure to end the last statement that you have in the block with a ; (semi-colon). You can also add more information - like if you want to call their telephone number, call $order->customer['telephone'], etc.

 

You can also put this on your order confirmation page or elsewhere as you might like.

 

Hope this helps!

Link to comment
Share on other sites

  • 1 year later...

hello everybody

unfortunately i got a bad problem with this !

i just rename one of my customer text field and change FAX to MOBILE and a new customer can register through my new text fileds successfully and also he can edit them without any problem and all details of customers insert in my mysql data bank successfully but my problem is in the admin area in the customers area where you can see your registered customers ! in that area all customers name and family name are shown but when you click on them you CAN NOT EDIT them ( you dont enter to the page to edit the filed ) and also you CAN NOT DELETE them and all summary fileds in the right place of every customers is empty like last logon last change country and etc !

i attached you the customers.php of my website .

can anyone help me !?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...