Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Customer order comments


14steve14

Recommended Posts

Posted

I am after suggestions on how to print the order comments left by customers on the bottom of the invoices.

 

I currently have a very modified invoice which started life as the invoice from the fancier invoice and packing slip addon. It shows the order comments on the bottom of the invoice. Now this includes all order comments and even those from the payment providers. I used to use an old version of the PayPal standard payment module which left virtually no information on the order comments section.

 

I have now installed the new PayPal app that leaves a shed load of comments in the orders page (Image included at bottom of post), many of them duplicated, and these I do not want printed on the invoice.

 

Would it be feasible to change the order comments table name where a customer leaves a comment when completing an order and have this printed on the invoice, or is there another way to do it.

 

The current code in the invoice for the comments code is

      <!-- ORDER COMMENTS CODE STARTS HERE //-->
    <div id="comments_open" style="position: relative;">
      <?php 
	$orders_status_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' order by date_added");
	if (tep_db_num_rows($orders_status_history_query)) {
 	  $has_comments = false;
     echo '      <br /><br />';
     echo '      <table width="100%" border="0" cellpadding="0" cellspacing="0">';
     echo '      	<tr>';
     echo '      		<td width="9"> </td>';
     echo '      		<td>';
     echo '      		<table width="100%" border="0" cellpadding="0" cellspacing="0">';
     echo '      				<td align="center" bgcolor="#ffffff">';
     echo '      				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
     echo '      					<tr>';
     echo '      						<td width="95%"> <b>' . TABLE_HEADING_COMMENTS . '</b><br /><br /></td>';
     echo '      					</tr>';

     while ($orders_comments = tep_db_fetch_array($orders_status_history_query)) {
     	 if (tep_not_null($orders_comments['comments'])) {
	      $has_comments = true; // Not Null = Has Comments
	      if (tep_not_null($orders_comments['comments'])) {
           $sInfo = new objectInfo($orders_comments);
           echo '      					<tr>';
           echo '      						<td align="center" width="95%">';
           echo '      						<table width="95%" border="0" cellpadding="0" cellspacing="0">';
           echo '      							<tr>';
           echo '      								<td width="95%" class="smallText">';
           echo '      								<table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
           echo '      									<tr>';
           echo '      										<td width="150" align="left" valign="top" class="smallText"><strong><u>' . TABLE_HEADING_DATE_ADDED . '</u></strong></td>';
           echo '      										<td align="left" valign="top" class="smallText"><strong><u>' . TABLE_HEADING_COMMENT_LEFT . '</u></strong></td>';
           echo '      									</tr>';
           echo '      								</table>';
           echo '      								</td>';
           echo '      							</tr>';
           echo '      						</table>';
           echo '      						</td>';
           echo '      					</tr>';
           echo '      					<tr>';
           echo '      						<td align="center" width="95%">';
           echo '      						<table width="95%" border="0" cellpadding="0" cellspacing="0">';
           echo '      							<tr>';
           echo '      								<td width="95%" class="smallText">';
           echo '      								<table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
           echo '      									<tr>';
           echo '      										<td width="150" align="left" valign="top" class="smallText">' . tep_date_short($sInfo->date_added) . '</td>';
           echo '      										<td align="left" valign="top" class="smallText">' . nl2br(tep_db_output($orders_comments['comments'])) . '<br /><br /></td>';
			  echo '      									</tr>';
			  echo '      								</table>';
           echo '      								</td>';
			  echo '      							</tr>';
           echo '      						</table>';
           echo '      						</td>';
           echo '      					</tr>';
	      }
       }
     }
     if ($has_comments == false) {
		 echo '           <tr>';
		 echo '            <td align="center" width="95%">';
		 echo '            <table width="95%" border="0" cellpadding="0" cellspacing="0">';
		 echo '             <tr>';
		 echo '              <td width="95%" class="smallText">';
		 echo '              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
		 echo '               <tr>';
		 echo '                <td width="100%" align="left" valign="top" class="smallText">' . INVOICE_TEXT_NO_COMMENT . '</td>';
		 echo '               </tr>';
		 echo '              </table>';
		 echo '              </td>';
		 echo '             </tr>';
		 echo '            </table>';
		 echo '            </td>';
		 echo '           </tr>';
     }
	  echo '      					<tr>';
	  echo '      						<td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
	  echo '      					</tr>';
	  echo '      				</table>';
	  echo '      		</table>';
	  echo '      		</td>';
	  echo '      	</tr>';
	  echo '      </table>';
	}
?>
      <!-- ORDER COMMENTS CODE ENDS HERE //-->

Customers leave info on where to leave parcels if not in, and other things. Some customers leave messages about their particular orders such as colours, so its easiest printed in the bottom of the invoice so both me and the customers can see the information.

 

The image below shows what the above code prints on the invoice.

 

(Edited to add image)

 

 

 

Any suggestions welcome.

REMEMBER BACKUP, BACKUP AND BACKUP

Posted

You could simply remove comments that have the status "Paypal [Transactions]" ?

 

 

Change the first SQL in what you posted to (change "X" to the order status you wish to remove, get that from the order status page in admin), note untested:

 

$orders_status_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " 
where orders_id = '" . tep_db_input($oID) . "' 
and orders_status_id != X
order by date_added");
If you wish to also remove updates that have blank comments, this might work (untested!):

 

$orders_status_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " 
where orders_id = '" . tep_db_input($oID) . "' 
and orders_status_id != X
and (comments is not null || comments != '')
order by date_added");
Posted

@@burt

 

Your first bit of code worked fine once I figured out that I needed to enter the number of the payment method from the database table for payment statuses.

 

Thank you very much

REMEMBER BACKUP, BACKUP AND BACKUP

Archived

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

×
×
  • Create New...