Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Trying to pull orders_status_history_id from the database


djmonkey1

Recommended Posts

Ok- I'm working on Order Editor (http://www.oscommerce.com/community/contributions,1435), and I'm trying to get it so that the shop owner can edit the comments associated with an order (at least one version of this contrib purports to having this functionality, however I have not found this to be the case). The section of code I'm working with currently looks like this:

 

<?php
$orders_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' order by date_added");
 /////why doesn't this work???////////////
 $orders_status_history_id = $order->status[$i]['history'][$j]['orders_status_history_id'];
 /////////////////////////////
 if (tep_db_num_rows($orders_history_query)) {
while ($orders_history = tep_db_fetch_array($orders_history_query)) {
  echo '  <tr>' . "\n" .
	  '	<td class="smallText" align="center">' . tep_datetime_short($orders_history['date_added']) . '</td>' . "\n" .
	  '	<td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
	   '	<td class="smallText" align="center">';
  if ($orders_history['customer_notified'] == '1') {
	echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . "</td>\n";
  } else {
	echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "</td>\n";
  }
 echo '	<td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
	  '	<td class="smallText" align="left">' . $orders_status_array[$orders_history['orders_status_id']] . '</td>' . "\n";
  if ($CommentsWithStatus) {
   echo '	<td class="dataTableHeadingContent" align="left" width="10"> </td>' . "\n" .
		/////////////////////////
	  ////HERE THEY ARE ///////
		'		<td class="' . $RowStyle . '" valign="top">' . "<input name='update_status[$orders_status_history_id][comments]' size='52' value='" . nl2br(tep_db_output($orders_history['comments'])) . "'>" . '</td>' . "\n";
		//'	<td class="smallText" align="left">' . nl2br(tep_db_output($orders_history['comments'])) . ' </td>' . "\n";
  //////////////////////////////
  //////////////////////////////
  }
  echo '  </tr>' . "\n";
}
 } else {
echo '  <tr>' . "\n" .
	'	<td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
	 '  </tr>' . "\n";
 }
 ?>

 

This results in an output that looks like this:

 

  <tr>
<td class="smallText" align="center">12/29/2005 15:30:20</td>
<td class="dataTableHeadingContent" align="left" width="10"> </td>
  <td class="smallText" align="center"><img src="images/icons/cross.gif" alt="False" title=" False " border="0"></td>
<td class="dataTableHeadingContent" align="left" width="10"> </td>
<td class="smallText" align="left">Cancelled</td>
<td class="dataTableHeadingContent" align="left" width="10"> </td>
	<td class="dataTableContent" valign="top"><input name="update_status[][comments]" size="52" value="This is a test of the comments editing system"></td>
 </tr>

 

The problem with this that I'm seeing is that in the input name "update_status[][comments]", there should be a numerical value inside the empty brackets, in this specific case the number 918. Obviously, that is not the case.

 

The way I'm led to understand it, by analyzing pre-existing code that functions just fine, the entry

 

$orders_status_history_id = $order->status[$i]['history'][$j]['orders_status_history_id'];

 

is telling the server that the variable $orders_status_history_id is the entry found in the table orders_status_history under the column heading orders_status_history_id. Apparently I don't know what the hell I'm talking about, as this code does not produce the desired result.

 

I don't understand what I'm doing wrong, and would greatly appreciate guidance.

 

Thanks,

Stew

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

the problem seems to be in the top part of the file

what i did was look for around line 140 to 150 in my vesion 1.56 or 1.57

it seems that it updates the wrong table and the if statment also has a problem that i did not look at but simply commented out i just compared to stock osc and i am sure you figure out the rest

	if(!$CommentsWithStatus)
{

  $UpdateOrders .= ", comments = '" . tep_db_input($comments) . "'";
	}

	$UpdateOrders .= " where orders_id = '" . tep_db_input($oID) . "';";

	tep_db_query($UpdateOrders);
	$order_updated = true;

and changed to

	//	if(!$CommentsWithStatus)
//	{


//$UpdateOrders .= ", comments = '" . tep_db_input($comments) . "'";
//	}

	$UpdateOrders .= " where orders_id = '" . tep_db_input($oID) . "';";

	tep_db_query($UpdateOrders);
		tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . tep_db_input($oID) . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments)  . "')");
	$order_updated = true;

this updated the comments but there still is the issue of email and notification

Link to comment
Share on other sites

this updated the comments but there still is the issue of email and notification

 

This is the question- under the current scheme, there is never any notification of the changes that are made. At first I was excited by the existence of this contribution as there are times when I legitimately need to change information pertaining to the order, however after thinking about it more it seems like a huge risk to have this thing installed. Any changes made are permanent and there is no record kept of what changes are made, where the changes are made, or what the data was before the change.

 

Personally I may go back to editing the database direct, it's more difficult but much less likely to be done by mistake.

 

Thank you very, very much for your help, Frank, I greatly appreciate it. I owe you big time.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Ahh, I see- what you've done is take a step towards addressing this issue. This way, every time you hit update an entry is written to the orders_status_history table with a time stamp, etc.

 

All that's left is for the user to add comments to indicate what changes were made and then at least some sort of record is being kept.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

But- my original problem remains. The ability to edit previous comments is still not there yet. Thanks again, I will keep looking at it.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...