Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order Comments Not Being Saved To DB


Guest

Recommended Posts

Posted

Any clues as to where I should look to fix this problem?

 

In the generated code in checkout_payment.php (the osC site I am working on is modified and doesn't use the checkout_confirmation page by the way), the textarea field seems to have been correctly displayed:

 

<textarea class="textarea" id="comments" name="comments" cols="80" rows="10">Text goes here</textarea>

 

This code towards the top of checkout_payment.php *I think* suggests that there is nothing in the $_POST['comments'] variable:

 

if (isset($_POST['comments']) && tep_not_null($_POST['comments'])) {
$comments = tep_db_prepare_input($_POST['comments']);
}

 

I have checked the code in includes/classes/order.php and in lines 214-227 it looks OK:

	  $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
					  'currency' => $currency,
					  'currency_value' => $currencies->currencies[$currency]['value'],
					  'payment_method' => $payment,
					  'cc_type' => '',
					  'cc_owner' => '',
					  'cc_number' => '',
					  'cc_expires' => '',
					  'shipping_method' => $shipping['title'],
					  'shipping_cost' => $shipping['cost'],
					  'subtotal' => 0,
					  'tax' => 0,
					  'tax_groups' => array(),
					  'comments' => (tep_session_is_registered('comments') && !empty($comments) ? $comments : ''));

 

If I change the last line of code to say:

'comments' => now());

 

this correctly writes the date and time into the comments field in the orders_status_history table in the DB.

 

Any ideas?

Posted

OK I think I have sorted it out, but I don't understand why it stopped working in the first place...

 

On line 139 on checkout_process.php I went to this code block:

 

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id, 
					  'orders_status_id' => $order->info['order_status'], 
					  'date_added' => 'now()', 
					  'customer_notified' => $customer_notification,
					  'comments' => $order->info['comments']);

 

I changed the last line to:

'comments' => tep_db_prepare_input($_POST['comments']));

 

The only thing I can think of is that I did a search and replace of deprecated PHP tags in all files (i.e. $PHP_POST_VARS > $_POST, $PHP_GET_VARS > $_GET, and so on). Would this have played a part in this problem occuring?

Archived

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

×
×
  • Create New...