Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Custom Fields Per Order


Recommended Posts

I am interested in adding data text fields to the bottom of the Order Information page (account_history_info.php). The data entered into these fields needs to be unique per order, saved to the database, and editable by the customer. Therefore once data is entered and saved to the database, it will show up the next time the same order history page is accessed. I would also like to receive an email each time one of these fields is changed. Can someone please help me out in creating this?

I did a search of the forums and did not see anything like this, so if there is already something for this please let me know. Thanks.

Link to comment
Share on other sites

I have come a long way in coding this, however I have reached an impasse.

The account_history_info.php page shows information on a particular customer order. Code in the original account_history_info.php identifies the order number with “$HTTP_GET_VARS['order_id']”. I can use this code to populate my data fields, but it does not work when used in tep_db_perform to save to the database. Can someone help me code this correctly?


Here is the full php code I am working with:


 $Id: account_history_info.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License


 if (!tep_session_is_registered('customer_id')) {
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));


 require(DIR_WS_CLASSES . 'order.php');
 $order = new order($HTTP_GET_VARS['order_id']);

 if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
   $primary = tep_db_prepare_input($HTTP_POST_VARS['primary']);
   $secondary = tep_db_prepare_input($HTTP_POST_VARS['secondary']);
   $website_address = tep_db_prepare_input($HTTP_POST_VARS['website_address']);
   $color_scheme = tep_db_prepare_input($HTTP_POST_VARS['color_scheme']);
   $files = tep_db_prepare_input($HTTP_POST_VARS['style']);
   $style = tep_db_prepare_input($HTTP_POST_VARS['files']);
   $other = tep_db_prepare_input($HTTP_POST_VARS['other']);

   {  $sql_data_array = array('orders_primary' => $primary,
                             'orders_secondary' => $secondary,
                             'orders_website_address' => $website_address,
                             'orders_color_scheme' => $color_scheme,
                             'orders_style' => $style,
                             'orders_files' => $files,
                             'orders_other' => $other);

     tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', "orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'");
// reset the session variables

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

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

 $account_query = tep_db_query("select orders_primary, orders_secondary, orders_website_address, orders_color_scheme, orders_style, orders_files, orders_other from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' and orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'");
 $account = tep_db_fetch_array($account_query);


Link to comment
Share on other sites

It appears to me that "(int)$HTTP_GET_VARS['order_id']" no longer holds the orders_id value when the tep_db_perform statement runs. I looked at 'includes/application_top.php' and 'includes/classes/order.php' to see if there was anything that could account for this. I even tried to equal $HTTP_GET_VARS['order_id'] to a variable and replaced, but this did not work either.


I tested by changing


tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', "orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'");




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


and all of the particular customer's order information in the database was changed, so I know the rest of the code is not the issue. I'm sure the answer is simple, I'm just new to php scripting. So could someone throw a php newb a bone here?

Link to comment
Share on other sites


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

  • Create New...