Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Customers extra fields


kit

Recommended Posts

Hello,

 

Great contribution. Everything worked for me without a hitch. For those of you having problems (and you have the newest stable osC), keep in mind that there are a few minor typos. For example, in step three "languages" is your language folder not a folder named languages. And "extrafields.php" is really "extra_fields.php". I had to bring that up, just in case.

 

3. Copy all files included in package to the same folder

/catalog/admin/extra_fields.php

/catalog/admin/includes/languages/extrafields.php

 

MINOR FIX TO THE "EMAIL" PART OF THIS CONTRIBUTION:

 

If you have multiple languages setup in your site then the following line from checkout_process.php will grab the very first record in the extra_fields_info table. I have three languages setup and I noticed that my fields_name was incorrect in the email.

 

Was this ...

$extrfieldsinf = tep_db_query("select fields_name from " . TABLE_EXTRA_FIELDS_INFO . " where fields_id = '" . $dataexfes['fields_id'] . "'");

 

I simply added the language check and it works...

 $extrfieldsinf = tep_db_query("select fields_name from " . TABLE_EXTRA_FIELDS_INFO . " where fields_id = '" . $dataexfes['fields_id'] . "' and languages_id ='" . $languages_id . "'");

 

Now folks, I will begin the very painful process of taking our brand new extra fields information and output it in the invoice and the Order Editor contribution (at least three spots there :'( ). I'll post updates as I get stuff working. Wish me luck.

Edited by Duende1

__

 

Duende

Link to comment
Share on other sites

Yes, THAT's what we need !!!!

I was thinking to try myself the invoice and order part, but I really have no time. so GOOD LUCK !

 

 

Hello,

 

Great contribution. Everything worked for me without a hitch. For those of you having problems (and you have the newest stable osC), keep in mind that there are a few minor typos. For example, in step three "languages" is your language folder not a folder named languages. And "extrafields.php" is really "extra_fields.php". I had to bring that up, just in case.

MINOR FIX TO THE "EMAIL" PART OF THIS CONTRIBUTION:

 

If you have multiple languages setup in your site then the following line from checkout_process.php will grab the very first record in the extra_fields_info table. I have three languages setup and I noticed that my fields_name was incorrect in the email.

 

Was this ...

$extrfieldsinf = tep_db_query("select fields_name from " . TABLE_EXTRA_FIELDS_INFO . " where fields_id = '" . $dataexfes['fields_id'] . "'");

 

I simply added the language check and it works...

 $extrfieldsinf = tep_db_query("select fields_name from " . TABLE_EXTRA_FIELDS_INFO . " where fields_id = '" . $dataexfes['fields_id'] . "' and languages_id ='" . $languages_id . "'");

 

Now folks, I will begin the very painful process of taking our brand new extra fields information and output it in the invoice and the Order Editor contribution (at least three spots there :'( ). I'll post updates as I get stuff working. Wish me luck.

Link to comment
Share on other sites

Yes, THAT's what we need !!!!

I was thinking to try myself the invoice and order part, but I really have no time. so GOOD LUCK !

 

Well, my friend I decided to use osC in my new job. So I'm getting paid for some of this -- although it's just one of many projects. I've used pay carts (.Net & Coldfusion) in the past and it just comes down to the type of pain you like. With these forums, contributions and a couple of books I just bought, I look forward to heavily modding my osC into a mean customer/product management tool.

 

I look forward to giving back.

__

 

Duende

Link to comment
Share on other sites

I got a little confused with some of the code entry, it seems like some of it works and other parts don't....Specifically when adding multiple fields, and when an existing customer goes to update thier information I get this message.

 

Parse error: parse error, unexpected $ in /home/content/C/I/P/CIPH9/html/C1pherstore/catalog/account_edit.php on line 290

 

I know there is an entry error in my code so here it is.

 

 

 

<?php

/*

$Id: account_edit.php,v 1.65 2003/06/09 23:03:52 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

if (!tep_session_is_registered('customer_id')) {

$navigation->set_snapshot();

tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

}

 

// needs to be included earlier to set the success message in the messageStack

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_EDIT);

 

if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {

if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);

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

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

if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);

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

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

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

 

$error = false;

 

if (ACCOUNT_GENDER == 'true') {

if ( ($gender != 'm') && ($gender != 'f') ) {

$error = true;

 

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

}

}

 

if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

$error = true;

 

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

}

 

if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

$error = true;

 

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

}

 

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);

}

}

 

if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

$error = true;

 

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

}

 

if (!tep_validate_email($email_address)) {

$error = true;

 

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

}

 

$check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id != '" . (int)$customer_id . "'");

$check_email = tep_db_fetch_array($check_email_query);

if ($check_email['total'] > 0) {

$error = true;

 

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

}

 

if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

$error = true;

 

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

}

$extra_fields_query = tep_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type, ce.fields_size from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status=1 and ce.fields_required_status=1 and cei.fields_id=ce.fields_id and cei.languages_id =" . $languages_id);

while($extra_fields = tep_db_fetch_array($extra_fields_query)){

if(strlen($HTTP_POST_VARS['fields_' . $extra_fields['fields_id']])<$extra_fields['fields_size']){

$error = true;

$string_error=sprintf(ENTRY_EXTRA_FIELDS_ERROR,$extra_fields['fields_name'],$extra_fields['fields_size']);

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

}

if ($error == false) {

$sql_data_array = array('customers_firstname' => $firstname,

'customers_lastname' => $lastname,

'customers_email_address' => $email_address,

'customers_telephone' => $telephone,

'customers_fax' => $fax);

 

if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;

if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);

 

tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");

 

tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'");

 

$sql_data_array = array('entry_firstname' => $firstname,

'entry_lastname' => $lastname);

 

tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'");

 

tep_db_query("delete from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id=" . $customer_id);

$extra_fields_query = tep_db_query("select ce.fields_id from " . TABLE_EXTRA_FIELDS . " ce where ce.fields_status=1 ");

while($extra_fields = tep_db_fetch_array($extra_fields_query)){

$sql_data_array = array('customers_id' => $customer_id,

'fields_id' => $extra_fields['fields_id'],

'value' => $HTTP_POST_VARS['fields_' . $extra_fields['fields_id']]);

tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);

}

 

 

// reset the session variables

$customer_first_name = $firstname;

 

$messageStack->add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success');

 

tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

}

}

 

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

$account = tep_db_fetch_array($account_query);

 

$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<?php require('includes/form_check.js.php'); ?>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><?php echo tep_draw_form('account_edit', tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'), 'post', 'onSubmit="return check_form(account_edit);"') . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

if ($messageStack->size('account_edit') > 0) {

?>

<tr>

<td><?php echo $messageStack->output('account_edit'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

?>

<tr>

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

<tr>

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

<tr>

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

<td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

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

<?php

if (ACCOUNT_GENDER == 'true') {

if (isset($gender)) {

$male = ($gender == 'm') ? true : false;

} else {

$male = ($account['customers_gender'] == 'm') ? true : false;

}

$female = !$male;

?>

<tr>

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

<td class="main"><?php echo tep_draw_radio_field('gender', 'm', $male) . '  ' . MALE . '  ' . tep_draw_radio_field('gender', 'f', $female) . '  ' . FEMALE . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>

</tr>

<?php

}

?>

<tr>

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

<td class="main"><?php echo tep_draw_input_field('firstname', $account['customers_firstname']) . ' ' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

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

<td class="main"><?php echo tep_draw_input_field('lastname', $account['customers_lastname']) . ' ' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>

</tr>

<?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_date_short($account['customers_dob'])) . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>

</tr>

<?php

}

?>

<tr>

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

<td class="main"><?php echo tep_draw_input_field('email_address', $account['customers_email_address']) . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

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

<td class="main"><?php echo tep_draw_input_field('telephone', $account['customers_telephone']) . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

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

<td class="main"><?php echo tep_draw_input_field('fax', $account['customers_fax']) . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?></td>

<tr>

<td><?php echo tep_get_extra_fields($customer_id, $languages_id)?></td>

</tr>

</tr>

</table></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

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

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

</table></form></td>

<!-- body_text_eof //-->

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

Link to comment
Share on other sites

Hi everybody !

 

I installed this contribution and everything works exept one thing:

 

I can't update the customers section in admin. For example when I try to modify one field and click on "update", the page loads again and nothing happens.

I have no problem to update my client informations in the shop (my account) but I can't do it the admin.

 

Any idea ?

 

Thanks a lot !

Link to comment
Share on other sites

It looks like no one has figured out how to put the extra fields on the invoice? Does anyone know the code so that we can SEE the extra fields on the invoice?

Link to comment
Share on other sites

It looks like no one has figured out how to put the extra fields on the invoice? Does anyone know the code so that we can SEE the extra fields on the invoice?

 

I'm taking a look at that now. Keep in mind that I have never created a contribution, I've been using osC for about a hectic month now, this is only one of a few high priority tasks, and I'm a former Coldfusion developer; so there will be some trial and error.

 

I still need to study how the order status and comments are handled, but at first glance it seems like most things are order-centric but our extra fields seem purely customer-centric. Tying it all together neatly will be an issue.

 

Another couple of days will show me if I'm way off course here, BUT I need to get this done and I don't have lots of time. As I wrap it up I'd love to chat with the contribution creator and a couple of others to help clean up my work. If an update comes out sooner then great, I can jump to my other tasks. :-"

 

To keep it simple-r I'm trying to modify in this order:

  1. Add extra fields to the invoice print out.
  2. Add the add/edit form to the admin/order details (original osC page)
  3. Add the add/edit form to the great Order Editor contribution (3 places).
  4. Add admin-only extra fields that will print out in the update emails and invoices.

__

 

Duende

Link to comment
Share on other sites

FOR emailing you can use this code: (I have tested this and it works for me)

 

// BEGIN Customers Extra Fields in Email

if (isset($customer_id)) {

$extra_fields_query = tep_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type, ce.fields_required_email from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status = '1' and ce.fields_required_email = '1' and cei.fields_id = ce.fields_id and cei.languages_id = " . (int)$languages_id);

 

if (tep_db_num_rows($extra_fields_query) > 0) {

//$email .= EMAIL_SEPARATOR . "\n" ;

 

while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {

$fields_name = '';

$value = '';

 

//if (isset($customer_id)) {

$value_query = tep_db_query("select value from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id = " . (int)$customer_id . " and fields_id = " . $extra_fields['fields_id']);

$value_info = tep_db_fetch_array($value_query);

$fields_name = $extra_fields['fields_name'];

$value = $value_info['value'];

//}

//$email .= "\n" . CATEGORY_EXTRA_FIELDS . "\n" . EMAIL_SEPARATOR . "\n";

$email .= $fields_name . ' : ' . $value . "\n";

}

$email .= "\n";

}

}

// END Customers Extra Fields in Email

 

Than change the $email variable to whatever your tep_mail function is using .. for example in admin/orders.php:

 

tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT_1 . ' ' . (int)$oID . ' / ' . EMAIL_TEXT_SUBJECT_2 . $orders_status_array[$status], $email, STORE_EMAIL_HEADER, STORE_BILLING_DEPT_EMAIL);

 

--------------------------------------------------------------------------------------------------------

 

For showing in invoices etc. you could use something like this .. although I have not actually tried adding this to anything yet. It is basically taken from the function tep_get_extra_fields in general.php

 

// BEGIN Customers Extra Fields in Email

if (isset($customer_id)) {

$extra_fields_query = tep_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type, ce.fields_required_email from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status = '1' and cei.fields_id = ce.fields_id and cei.languages_id = " . (int)$languages_id);

$extra_fields_string = '';

 

if (tep_db_num_rows($extra_fields_query) > 0) {

$extra_fields_string .= '<tr><td class="main"><b>' . CATEGORY_EXTRA_FIELDS . '</b></td></tr>';

$extra_fields_string .= '<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"><tr class="infoBoxContents"><td><table border="0" cellspacing="2" cellpadding="2">';

 

while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {

$fields_name = '';

$value = '';

 

//if (isset($customer_id)) {

$value_query = tep_db_query("select value from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id = " . (int)$customer_id . " and fields_id = " . $extra_fields['fields_id']);

$value_info = tep_db_fetch_array($value_query);

$fields_name = $extra_fields['fields_name'];

$value = $value_info['value'];

//}

 

$extra_fields_string .= '<tr>

<td class="main" valign="top">' . $fields_name . ' : ' . $value . '</td></tr>';

 

}

$extra_fields_string .= '</td></tr></td></tr>';

$extra_fields_string .= '<tr><td></td></tr>';

 

}

return $extra_fields_string;

}

// END Customers Extra Fields in Email

 

Than echo the variable $extra_fields_string where you want the info to show up:

 

<?php echo $extra_fields_string; ?>

 

You might have to play around with the code because $customer_id is sometime $cID etc ... depending on what file your adding code to. OSC is very inconsistent and the code is very different from file to file.

Edited by insomniac2
Link to comment
Share on other sites

If you do not have a development copy of osC Please don't use this code. It's a first draft that seems to be working -- Trying to copy, paste and format these instructions in this post, I could have easily introduced typos.

 

I'm glad insomniac2 jumped on this ... I'll have to see about the email part as there is already an update for emailing (that works for me, at least). Anyways ... here's the first draft of some code to get the invoice to print the extra fields. As insomniac2 mentioned, we have enough code in this contribution to help generate the extra fields almost anywhere, although I believe it was only missing the invoice integration. Everything else (add/edit forms, etc) should be easier and I'll get working on Order Editor.

 

Below I tried to mimic the structure used within osC without changing anything, per se. I wanted to simply get an extra piece of information into queries that are already being run. Then use that extra "id" info for tying together orders/customers/extra_fields, etc.

  • FILE: admin/includes/classes/order.php
  • LINE ~13
  • NOTE- We need to add a variable to hold our extra fields info.

FIND:

  class order {
var $info, $totals, $products, $customer, $delivery, $content_type;

function order($order_id = '') {
	  $this->info = array();

 

 

REPLACE:

  class order {
var $info, $extra_fields, $totals, $products, $customer, $delivery;

function order($order_id) {
	  $this->info = array();
	  $this->extra_fields = array();

  • FILE: admin/includes/classes/order.php
  • LINE ~28
  • NOTE - The only change for the following find/replace is the addition of "customers_id" to the order_query.

FIND:

$order_query = tep_db_query("select customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id. "'");

 

REPLACE:

$order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

  • FILE: admin/includes/classes/order.php
  • LINE ~48
  • Only added 'cust_id' => $order['customers_id'], to the "$this->customer = array" -- don't forget the comma.

$this->customer = array('cust_id' => $order['customers_id'],
	'name' => $order['customers_name'],
			'company' => $order['customers_company'],
	   	'street_address' => $order['customers_street_address'],
			'suburb' => $order['customers_suburb'],
			'city' => $order['customers_city'],
			'postcode' => $order['customers_postcode'],
			'state' => $order['customers_state'],
			'country' => $order['customers_country'],
			'format_id' => $order['customers_address_format_id'],
			'telephone' => $order['customers_telephone'],
			'email_address' => $order['customers_email_address']);

  • FILE: admin/invoice.php
  • NOTE - This output is its own table that can be placed above the "Comments" on the invoice.php. Seeing how there are a number of different invoice layouts available, then I suggest plugging this in above the comments section and below the products. Otherwise just take your time and work with the formatting.

<!-- PRINT EXTRA FIELDS CODE STARTS HERE //-->
<?php 
$orders_extrafields_query = tep_db_query("SELECT DISTINCT o.customers_id, cte.value, efi.fields_name, o.customers_name FROM " 

.TABLE_EXTRA_FIELDS_INFO. " efi INNER JOIN " .TABLE_CUSTOMERS_TO_EXTRA_FIELDS. " cte ON (efi.fields_id = cte.fields_id) INNER JOIN " 

.TABLE_ORDERS. " o ON (cte.customers_id = o.customers_id) WHERE (efi.languages_id = '".$languages_id."') AND (o.customers_id ='". 

tep_db_input($order->customer['cust_id']) ."') ORDER BY cte.fields_id ASC");

	if (tep_db_num_rows($orders_extrafields_query)) {
		$has_extrafields = false;
		echo '		<tr>';
		echo '		  <td width="95%">' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
		echo '		</tr>';			
		echo '	<table width="95%" width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
		echo ' 		<tr>';
		echo '	 		<td><strong>' . TABLE_HEADING_EXTRAFIELDS . ':</strong><br><br></td>';
		echo '	 	</tr>';

		while ($orders_extrafields = tep_db_fetch_array($orders_extrafields_query)) {
			if (tep_not_null($orders_extrafields['value'])) {
				$has_extrafields = true;// Not Null = Has Extra Fields
				if (tep_not_null($orders_extrafields['value'])) {
					$exInfo = new objectInfo($orders_extrafields);
					echo '<tr>';
					echo '	<td width="95%">';
					echo '		<strong>' . nl2br(tep_db_output($orders_extrafields['fields_name'])) 

.':</strong><br /><span class="smallText">' . nl2br(tep_db_output($orders_extrafields['value'])) . '</span><br /><br />';
					echo '	</td>';
					echo '</tr>';			

				}
			}
		}
		 if ($has_extrafields == false) { /*most of this stuff is row-to-row ending the section (with a FINAL row to end the table) */


			echo '		<tr>';
			  echo '		  <td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
			  echo '		</tr>';
		 }
			echo '		<tr>';
			  echo '		  <td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
			  echo '		</tr>';
		 	echo '	</table>';
	}
?> 
<!-- PRINT EXTRA FIELDS CODE ENDS HERE //-->

Edited by Duende1

__

 

Duende

Link to comment
Share on other sites

Evidently, my last edit bombed out and now I can no longer edit ... oh well.

  • FILE: admin/includes/languages/#your_language#/invoice.php
  • NOTE - Add the following line to define the Extra Fields Heading.

define('TABLE_HEADING_EXTRAFIELDS','ADDITIONAL ACCOUNT INFORMATION');

 

... also I can't get my separator function to work above my Extra Fields heading on my invoice. Recently I just removed that and placed a " hr size="3" " tag. :)

__

 

Duende

Link to comment
Share on other sites

Duende1 .. your code for invoice is working great ... but each customer extra field is listed twice (ie .. duplicated)

 

I will try to figure it out if I get a chance.

 

Nice work though.

 

 

As for the email customer extra fields ... zoulxp's email mod did not work for me ... was duplicating all the fields too. So I had to take the code out of general.php and reworked it.

Edited by insomniac2
Link to comment
Share on other sites

Duende1 .. your code for invoice is working great ... but each customer extra field is listed twice (ie .. duplicated)

 

I will try to figure it out if I get a chance.

 

Nice work though.

As for the email customer extra fields ... zoulxp's email mod did not work for me ... was duplicating all the fields too. So I had to take the code out of general.php and reworked it.

 

I see your point about the email. I re read the post and remembered that there were email issues. As for the double data output I wonder if it's a language ID issue? Either duplicate language ID's (that may have popped in during testing) or if the query is just weak, poorly written and ignores an intended constraint? I have multiple languages available and like the original email add-on, I don't get duplicates. So I'm definitely curious. Perhaps I need to remove my extra languages and see what happens.

 

Anyway, I have to move on to some reporting and then back to adding extra fields to the Order Editor ... then see about Admin only extra fields.

__

 

Duende

Link to comment
Share on other sites

Anyone know how to make the text box a drop down instead??

 

Hi,

 

I just popped back over to see what's doing. [aside] BTW: I just modified a recipe from Monika Mathe's, Deep Inside osCommerce: The Cookbook, to search the order "comments" (we'll be adding serial numbers when products ship) from the generic order listing within admin. She's damn impressive ... her recipe gets bundled into an existing query as a sub query. Got an error on the "back" button, though but nothing too terrible.[/aside]

 

Anyway, my brain's a bit frazzled. Where exactly do you want these drop downs and what will be populated within them? I haven't looked yet but I suspect that form elements are generated with some form of "tep_" function. Let me know what you're looking for because I might need it too :-"

 

...ciao

__

 

Duende

Link to comment
Share on other sites

Hi,

 

 

I installed this Contribution and was having an Error message stating I am missing a column in the table. I added the 'fields_required_email' column into the extra_fields table (in the database) and then it all seemed to work. The only thing now is that the OSC no longer sends the Order E-mails to the merchant (it just sends it to the Customer) and it does not include the extra fields in the E-mail either. I read the posts above and I also would like to ask which files I suppose to Edit to add the information from these fields to Confirm E-mails and Orders that show up in Admin?

 

 

I really have ONE BIG problem - I need to set OSC so that the customer would FIRST fill out the Recipient INFO and card message (to send flowers to SOMEONE ELSE) and then fill out his/her own info. I installed the 'extra fields Contrib' and so I have most of the information on one page and the customer has the option to register OR not when they are done filling out the form. See - the ORDER CONFIRMATION page on OSC does give you the option to EDIT the Delivery Address and also the Billing Information but it takes fore granted that the Delivery Address is automatically the same as the Billing Address. Please - would anyone know how I could make it so that the customer would have to FILL IN THE DELIVERY (RECIPIENT) ADDRESS FIRST?

 

 

Thank you so much for all your help! ;)

 

 

 

Jan Mares

Edited by romantix
Link to comment
Share on other sites

Hi again :thumbsup:

 

I think the problem with sending E-mail Confirmation to the merchant is an old problem I have had since almost the beginning (installing OSC). I remembered that I have to change the "Send Extra Order Emails To" field in order for the merchant to receive a copy of the ORDER CONFIRMATION.

 

Now, I just looked everywhere - in the Confirm E-mails both on Client and merchant side, the orders themselves in Admin-Customers, in the Customer profiles, invoices and I don't see the contents of the extra fields anywhere! Please tell me what I did wrong??? I thought the idea of this Contrib was to actually capture the data that the customer fills in to these extra fields?

 

 

The only thing that I know I have done differently during the installation of this Contribution was in one step (STEP 13 - In catalog/create_acount.php) --> since I don't use the create_acount.php but instead use create_account1.php because I installed the Fast Easy Checkout Contribution --) I couldn't change the last 2 things in that step because I don't have them in that file. Those are:

 

 

Find: if ($error == false) { AND ADD SOMETHING BEFORE THIS

 

and

 

Find: $customer_id = tep_db_insert_id(); AND ADD SOMETHING AFTER THIS

 

 

 

Please, please - someone help me! I am very gratefull for any replies.

 

Thank you so much!

 

 

 

Jan Mares

 

 

 

 

 

 

 

Hi,

 

 

I installed this Contribution and was having an Error message stating I am missing a column in the table. I added the 'fields_required_email' column into the extra_fields table (in the database) and then it all seemed to work. The only thing now is that the OSC no longer sends the Order E-mails to the merchant (it just sends it to the Customer) and it does not include the extra fields in the E-mail either. I read the posts above and I also would like to ask which files I suppose to Edit to add the information from these fields to Confirm E-mails and Orders that show up in Admin?

 

 

I really have ONE BIG problem - I need to set OSC so that the customer would FIRST fill out the Recipient INFO and card message (to send flowers to SOMEONE ELSE) and then fill out his/her own info. I installed the 'extra fields Contrib' and so I have most of the information on one page and the customer has the option to register OR not when they are done filling out the form. See - the ORDER CONFIRMATION page on OSC does give you the option to EDIT the Delivery Address and also the Billing Information but it takes fore granted that the Delivery Address is automatically the same as the Billing Address. Please - would anyone know how I could make it so that the customer would have to FILL IN THE DELIVERY (RECIPIENT) ADDRESS FIRST?

 

 

Thank you so much for all your help! ;)

 

 

 

Jan Mares

Edited by romantix
Link to comment
Share on other sites

  • 2 weeks later...

I still got one problem, Mine still shows this:

 

 

 

 

Fields Status Action

1146 - Table 'loverazo_osc1.extra_fields' doesn't exist

 

select count(*) as total from extra_fields ce, extra_fields_info cei where cei.fields_id=ce.fields_id and cei.languages_id =1

 

[TEP STOP]

 

 

 

 

I looked through everything and I did it all correctly (or so I think). Does anyone know whats wrong and what I have to change?

Link to comment
Share on other sites

Hi every body,

 

My problem is still not resolved :(

 

Does anybody have an idea ?

 

 

"I installed this contribution and everything works exept one thing:

 

I can't update the customers section in admin. For example when I try to modify one field and click on "update", the page loads again and nothing happens.

I have no problem to update my client informations in the shop (my account) but I can't do it the admin."

 

Thanks a lot !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...