I am attempting to add additional customer fields into a new table which I have called customers_additional. I have successfully followed the instructions posted http://www.zen-cart.com/forum/showpo...6&postcount=14 and http://www.zen-cart.com/forum/showpo...6&postcount=15 (thanks!).
The new customer fields can be created by the customer and edited from Admin. However, I am unable to display the additional fields in the account_edit page. From trouble-shooting, I've found that if I add a print_r($account) to includes/modules/pages/account_edit/header.php, the new fields appear in the array. This demonstrates that the query is working. However, when I add a print_r($account) to includes/templates/MY_TEMPLATE/tpl_account_edit_default.php the new fields do not appear!
Please tell me what's going on between loading the header and loading the template. Any insight would be appreciated.
My new table is defined in /includes/database_tables.php:
The $account is set in includes/modules/pages/account_edit/header.php:PHP Code:define('TABLE_CUSTOMERS_ADDITIONAL', DB_PREFIX . 'customers_additional');
The customer fields are displayed in: includes/templates/MY_TEMPLATE/tpl_account_edit_default.php:PHP Code:// Start replacement query for Customer Additional Info
/*$account_query = "SELECT customers_gender, customers_firstname, customers_lastname,
customers_dob, customers_email_address, customers_telephone,
customers_fax, customers_email_format, customers_referral
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";
*/
$account_query = "SELECT ca.customers_id, ca.emergency1_firstname, ca.emergency1_lastname,
c.customers_gender, c.customers_firstname, c.customers_lastname,
c.customers_dob, c.customers_email_address, c.customers_telephone,
c.customers_fax, c.customers_email_format, c.customers_referral
FROM " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_ADDITIONAL . " ca
WHERE c.customers_id = :customersID
AND ca.customers_id = :customersID ";
// End replacement query for Customer Additional Info
$account_query = $db->bindVars($account_query, ':customersID', $_SESSION['customer_id'], 'integer');
$account = $db->Execute($account_query);
print_r($account); // correctly displays customer fields from customers and customers_additional tables
PHP Version: 5.2.11HTML Code:<!-- Added for Customer Additional Fields --> <fieldset> <legend class="alert"><?php echo TABLE_HEADING_CUSTOMER_ADDITIONAL_DETAILS; ?></legend> <?php print_r($account); ?> // DISPLAYS THE CUSTOMER FIELDS BUT NOT THE CUSTOMER_ADDITIONAL FIELDS <?php echo 'TEST' . $account->fields['emergency1_firstname']; //DOES NOT DISPLAY ?>
Zen Cart 1.3.8a
Database: MySQL 5.0.85



