Hello to all, this just to share my findings about this product.
Good the idea and the design just some slips in coding i think. :smile:
Thanks to theOracle!
The consideration will be in sparse order as i remember the notes, i'm sorry if I repeat information already seen.
As a general advice, do your tests creating customer_cellphone that is already well configured by theoracle in the files, less doubts.
First :
The problem of not seeing the combos populated in create field page.
My answer : the javascript files that populate the combos etc... reside in a directory called
[ZENDIR]admin\includes\javascript\mods\additional_customers_fields**english
**Now if you speak a different language (I'm from Italy) it will not find the files so you have to create a dir with your language and copy the contained files
**NOTE: Take care of this point for all the dirs that end with english and the involved files
**Second :
Empty areas instead of fields in Admin/Customer Edit if values are not there.
It seems a design choice so nothing to say, in the forum there is the modification for avoiding it
Third:
**Empty areas in Customer part (for Edit account)
**This was tricky and (shame on me) I don't remember well if it was present only for edit account or also for create.
In any case (remember I speak of my particular case) It was solved when I recognized that
-
the account informations are retrieved from the DB in a file called header_php.php
-
the install instructions say that you have to compare
[ZENDIR]includes/modules/pages/account_edit/<your_template>/header_php.php
which I had not in my dirs, as I had only
[ZENDIR]includes/modules/pages/account_edit/header_php.php
without template references.
- That instead of comparing at the end of the story I copied that file actually creating the
[...]account_edit/<your_template>/header_php.php
Now it seems (beware i'm not a zen expert) that in modules/pages/account_edit templating doesn't work (and it makes sense for me as it is business logic) so simply the new header_php.php didn't work.
Solution : I just copied it in [ZENDIR]includes/modules/pages/account_edit/header_php.php and voila' it worked and filled the fields
Fourth: **
sql errors during creation and editing (you have an error in 'UPDATE... blah blah)
**
It seems that theOracle doesn't like empty fields.:smile:
Now if at least one of the additional field has a value (i.e. you have a compo or a radio group) you won't see the problem.
The problems originate from the fact that the sql queries are built adding sql to the original ones but the additional sql is filled only if there are values so simply the strings are built uncorrectly if there is no value in a field (side effect : you can't empty a filled field)
Here I will post the modification I did hoping that a new version is done for everyone by the author
**Note for theOracle : **the cycle actually builds the $additionalsql string putting every field twice, is this normal ?
Original create_account.php
```php
// Additional customers fields.
$additional_sql = "";
$table_fields = $db->get_table_fields(TABLE_CUSTOMERS);
if (isset($table_fields) && !empty($table_fields)) {
foreach ($table_fields as $key => $val) {
if (!in_array($key, $customers_table_fields)) {
$key = zen_output_string_protected($key);
if (isset($POST[$key]) && isset($table_fields[$key]) && eregi("^[[:alnum:]][a-z0-9.-]*@[a-z0-9.-]+.[a-z]{2,6}$", zen_db_prepare_input($_POST[$key])) && zen_validate_email($_POST[$key]) == true) {
$additional_sql .= "$key = '".zen_db_prepare_input($_POST[$key])."', ";
} elseif (isset($POST[$key]) && isset($table_fields[$key]) && preg_match("/[a-zA-Z0-9.,;:%&#@!^-~`"'[]{}*/?()\n\r]/", $_POST[$key])) {
$additional_sql .= "$key = '".zen_db_prepare_input(strip_tags($_POST[$key]))."', ";
} // End of if statement.
} // End of if statement.
} // End of foreach statement.
} // End of if statement.
if (isset($additional_sql) && !empty($additional_sql)) {
$additional_sql .= substr($additional_sql, 0, strlen($additional_sql) -2);
} // End of if statement.
$sql = "update " . TABLE_CUSTOMERS . "
set customers_default_address_id = '" . (int)$address_id . "', " . zen_db_output($additional_sql) . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "'";
$db->Execute($sql);
// End of additional customers fields.
**Modified version from mine**
```php
// Additional customers fields.
$additional_sql = "";
$table_fields = $db->get_table_fields(TABLE_CUSTOMERS);
if (isset($table_fields) && !empty($table_fields)) {
foreach ($table_fields as $key => $val) {
if (!in_array($key, $customers_table_fields)) {
$key = zen_output_string_protected($key);
if (isset($_POST[$key]) && isset($table_fields[$key]) && eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", zen_db_prepare_input($_POST[$key])) && zen_validate_email($_POST[$key]) == true) {
$additional_sql .= "$key = '".zen_db_prepare_input($_POST[$key])."', ";
} elseif (isset($_POST[$key]) && isset($table_fields[$key]) && preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $_POST[$key])) {
$additional_sql .= "$key = '".zen_db_prepare_input(strip_tags($_POST[$key]))."', ";
} // End of if statement.
} // End of if statement.
} // End of foreach statement.
} // End of if statement.
if (isset($additional_sql) && !empty($additional_sql)) {
$additional_sql .= substr($additional_sql, 0, strlen($additional_sql) -2);
$additional_sql=','.$additional_sql;//LBTBD comma added only if there is additional sql
} // End of if statement.
$sql = "update " . TABLE_CUSTOMERS . "
set customers_default_address_id = '" . (int)$address_id . "' " . zen_db_output($additional_sql) . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "'";//LBTBD deleted comma
$db->Execute($sql);
// End of additional customers fields.
```
**Original account_edit\header_php.php (now not in your_template)**
```php
// Additional customers fields.
$additional_sql = "";
$table_fields = $db->get_table_fields(TABLE_CUSTOMERS);
if (isset($table_fields) && !empty($table_fields)) {
foreach ($table_fields as $key => $val) {
if (!in_array($key, $customers_table_fields)) {
$key = zen_output_string_protected($key);
if (isset($_POST[$key]) && isset($table_fields[$key]) && eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", zen_db_prepare_input($_POST[$key])) && zen_validate_email($_POST[$key])) {
$additional_sql .= "$key = '".zen_db_prepare_input($_POST[$key])."', ";
} elseif (isset($_POST[$key]) && isset($table_fields[$key]) && preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $_POST[$key])) {
$additional_sql .= "$key = '".zen_db_prepare_input(strip_tags($_POST[$key]))."', ";
} // End of if statement.
} // End of if statement.
} // End of foreach statement.
} // End of if statement.
if (isset($additional_sql) && !empty($additional_sql)) {
$additional_sql .= substr($additional_sql, 0, strlen($additional_sql) -2);
} // End of if statement.
$sql_update = "
UPDATE ".TABLE_CUSTOMERS."
SET " . $additional_sql . "
WHERE customers_id = :customersID";
$sql_update = $db->bindVars($sql_update, ':customersID', $_SESSION['customer_id'], 'integer');
$db->Execute($sql_update);
} // End of if statement.
// End of additional customers fields.
Modified version (which also empties already filled fields)
// Additional customers fields.
$additional_sql = "";
$table_fields = $db->get_table_fields(TABLE_CUSTOMERS);
//LBTBD
//foreach ($table_fields as $key => $val)
//{
// $debug.= $key.'-'.$val.'<br>';
//}//end LBTBD
if (isset($table_fields) && !empty($table_fields)) {
foreach ($table_fields as $key => $val) {
if (!in_array($key, $customers_table_fields)) {
$key = zen_output_string_protected($key);
if (isset($_POST[$key]) &&
isset($table_fields[$key]) &&
eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", zen_db_prepare_input($_POST[$key])) &&
zen_validate_email($_POST[$key]))
{
$additional_sql .= "$key = '".zen_db_prepare_input($_POST[$key])."', ";
}
elseif (isset($_POST[$key]) &&
isset($table_fields[$key]) &&
preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $_POST[$key]))
{
$additional_sql .="$key = '".zen_db_prepare_input(strip_tags($_POST[$key]))."', ";
}
//LBTBD manages empty values
elseif (isset($_POST[$key]) &&
isset($table_fields[$key]) &&
$_POST[$key]==''
)
{
$additional_sql .="$key = '".zen_db_prepare_input(strip_tags($_POST[$key]))."', ";
} //LBTBD manages empty values
} // End of if statement.
} // End of foreach statement.
} // End of if statement.
if (isset($additional_sql) && !empty($additional_sql)) {
$additional_sql .= substr($additional_sql, 0, strlen($additional_sql) -2);
} // End of if statement.
$sql_update = "
UPDATE ".TABLE_CUSTOMERS."
SET " . $additional_sql . "
WHERE customers_id = :customersID;";//LBTBD
$sql_update = $db->bindVars($sql_update, ':customersID', $_SESSION['customer_id'], 'integer');
$db->Execute($sql_update);
} // End of if statement.
// End of additional customers fields.
I must say that for now i have not tested the orders checkout blah blah
Test my modifications to see if are correct
Bye guys
Luca