Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Updating multiple orders status


Guest

Recommended Posts

Hi All,

 

Im looking for a mod that will allow me to update the order status for multiple orders, probably through a drop down list for each order in the order.php file. Does anyone know if this exists.

 

Also, is it possible to list orders in this screen based on their status, ie. show unprocessed orders first?

Link to comment
Share on other sites

I made a script that I call "quick ship". It lists all the orders that are pending on one big page and a checkbox next to it. There is a button on the bottom and when submitted will automatically change each order status to "shipped" and also send the customer / extra emails.

 

I need to finish it off but is mostly functional. I'll post it as a contribution in a little while...

Link to comment
Share on other sites

Better yet...create a blank page under the admin directory called "quickship.php". Paste this code and save:

<?php
/*
 quickship.php - Chemo
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
echo '<div class="dataTableContent" align="left">';
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 echo "There were ".sizeof($_POST)." records submitted.<br>";
 
function quickship($oID, $status='', $track=''){
     $order_updated = false;
  
    $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased, tracking from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'");
 $check_status = tep_db_fetch_array($check_status_query);
 
 $orders_statuses = array();
 $orders_status_array = array();
 $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = 1");
 while ($orders_status = tep_db_fetch_array($orders_status_query)) {
   $orders_statuses[] = array('id' => $orders_status['orders_status_id'],
                              'text' => $orders_status['orders_status_name']);
   $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
 }


  if ($status!==''){   
    if ($check_status['orders_status'] !== $status) {
       tep_db_query("update " . TABLE_ORDERS . " set orders_status = '". $status . "', last_modified = now() where orders_id = '" . $oID . "'");
       $customer_notified = '0';
 
       $notify_comments = '';
         $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
         tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
       $customer_notified = '1';
       
 tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments)  . "')");
       // MS1 Code
 //tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, new_value, old_value, date_added, customer_notified) values ('" . $oID . "', '" . $status . "', '" . $check_status['orders_status'] . "', now(), '" . $customer_notified . "')");

       $order_updated = true;
    	 }
  }
  
  if ($track!==''){   
    if ($check_status['tracking'] !== $track) {
       tep_db_query("update " . TABLE_ORDERS . " set tracking = '" . $track . "' where orders_id = '" . $oID . "'");
       $order_updated = true;
       }
  }   
 }

if ($_POST['update']=='1') {
foreach ($_POST as $i => $v){
//echo "$i - $v<br>";
list($o, $f) = explode("_", $i);
   if (is_numeric($o)){

if ($f=="check")
 {
	 quickship($o, '3', '');
	 echo "Order# $o, <b>$f</b> = $v (DATABASE UPDATED)<br>";
 }
 
if ($f=="track" && $v!=='')
 {
	 quickship($o, '', $v);
	 echo "Order# $o, <u>$f</u> = $v (DATABASE UPDATED)<br>";
 }

//End is_numeric
}
}
//If HTTP_POST end
}
echo '</div>';
include(DIR_WS_CLASSES . 'order.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php
 require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><? echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
           <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <!-- <tr><?php echo tep_draw_form('orders', 'quickship.php', '', 'get'); ?>
               <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('oID', '', 'size="12"') . tep_draw_hidden_field('action', 'edit'); ?></td>
             </form></tr>
             <tr><?php echo tep_draw_form('status', 'quickship.php', '', 'get'); ?>
               <td class="smallText" align="right"><?php echo HEADING_TITLE_STATUS . ' ' . tep_draw_pull_down_menu('status', $orders_statuses, '', 'onChange="this.form.submit();"'); ?></td>
             </form></tr> -->            
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
    <tr class="dataTableHeadingRow">
      <td class="dataTableHeadingContent" align="center">Ship</td>     
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
   <td class="dataTableHeadingContent" align="center">Order #</td>
   <td class="dataTableHeadingContent" align="center">Tracking #</td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
    	 <td class="dataTableHeadingContent" align="center">Invoice</td>          
    </tr>
<?php
   if ($HTTP_GET_VARS['cID']) {
     $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
     $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . tep_db_input($cID) . "' and o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and ot.class = 'ot_total' order by o.customers_name ASC";
   } elseif ($HTTP_GET_VARS['status']) {
     $status = tep_db_prepare_input($HTTP_GET_VARS['status']);
     $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and s.orders_status_id = '" . tep_db_input($status) . "' and ot.class = 'ot_total' order by o.customers_name ASC";
   } elseif ($HTTP_POST_VARS['status']) {
     $status = tep_db_prepare_input($HTTP_POST_VARS['status']);
     $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and s.orders_status_id = '" . tep_db_input($status) . "' and ot.class = 'ot_total' order by o.customers_name ASC";
} else {
     $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and s.orders_status_id = '1' and ot.class = 'ot_total' order by o.customers_name ASC";
   }
   $orders_split = new splitPageResults($HTTP_GET_VARS['page'], 200, $orders_query_raw, $orders_query_numrows);
   $orders_query = tep_db_query($orders_query_raw);
echo tep_draw_form('quickship', 'quickship.php', '', 'post');
while ($orders = tep_db_fetch_array($orders_query)) {
     if (((!$HTTP_GET_VARS['oID']) || ($HTTP_GET_VARS['oID'] == $orders['orders_id'])) && (!$oInfo)) {
       $oInfo = new objectInfo($orders);
     }
  $id = $orders['orders_id']; 
   $tracking_query = tep_db_query("select tracking from " . TABLE_ORDERS . " where orders_id = '" . $id . "'");
   $tracking = tep_db_fetch_array($tracking_query);

  if ($orders['orders_status_name'] == "Shipped") {$checkedlogic=false;} else {$checkedlogic=false;}     
?>    
   <tr class="dataTableRow">
   <td class="dataTableContent" align="center"><?php echo tep_draw_checkbox_field($id."_".'check', '', $checkedlogic); ?></td>
               <td class="dataTableContent" align="center"><?php echo $orders['customers_name']; ?></td>
               <td class="dataTableContent" align="center"><?php echo $orders['orders_id'] ?></td>
   <td class="dataTableContent" align="center"><?php echo tep_draw_input_field($id."_".'track', $tracking['tracking'], ''); ?></td>
   <td class="dataTableContent" align="center"><?php echo strip_tags($orders['order_total']); ?></td>
               <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td>
   <td class="dataTableContent" align="center"><?php echo $orders['orders_status_name']; ?></td>
      <td class="dataTableContent" align="center"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $orders['orders_id']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a>' ?></td>
    </tr>
<?php
   }
?>         <input type="hidden" name="status" value="1">
	 <input type="hidden" name="update" value="1">
     <?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE, ''); ?></form>
             <tr>
               <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="smallText" valign="top"><?php echo $orders_split->display_count($orders_query_numrows, 200, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS); ?></td>
                   <td class="smallText" align="right"><?php echo $orders_split->display_links($orders_query_numrows, 200, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'oID', 'action'))); ?></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>

   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php
   require(DIR_WS_INCLUDES . 'footer.php');
?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Call the page in the browser (www.yourdomain.com/admin/quickship.php) and tell me how it works for you!

Link to comment
Share on other sites

Hi There.

 

Thanks for sharing this, im sure we can get it working top notch!

 

Ive installed as stated and im getting the following as the table headings.

 

Ship TABLE_HEADING_CUSTOMERS Order # Tracking # TABLE_HEADING_ORDER_TOTAL TABLE_HEADING_DATE_PURCHASED TABLE_HEADING_STATUS Invoice

 

And a blank page under that.

Link to comment
Share on other sites

I uploaded the script as a contribution...see this update: http://www.oscommerce.com/community/contributions,2651

 

I have added install directions to add the link to the customers box and also an updated script that does not have the tracking info.

 

I originally created the script for a client that wanted to have tracking info added to each order so the customer could click a link to track the order. So, the script above was a cut-n-paste and I forgot that it had the tracking stuff in there :) Sorry...

 

Get the new contribution and just overwrite the file with the one provided.

 

Let me know how it works for you!

Link to comment
Share on other sites

Hi Chemo

 

Great contrib! How do I change the default from listing all orders in Pending to all those in Processing?

 

Edit: Don't worry, I found it! If anyone's interested, find:

 

} else {
     $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and s.orders_status_id = '1' and ot.class = 'ot_total' order by o.customers_name ASC";
   }

 

and change: s.orders_status_id = '2'

 

Gaz

Link to comment
Share on other sites

Thanks for that,

 

However, the page doesnt display any orders?

 

Could there be a reason for this?

See the post above...the orders_status_id is hardcoded. Just change it to whatever you want to display.

 

Also, make sure to change this code as well:

if ($_POST['update']=='1') {
echo '<div class="dataTableContent" align="left">';
foreach ($_POST as $i => $v){
//echo "$i - $v<br>";
list($o, $f) = explode("_", $i);
   if (is_numeric($o)){	
if ($f=="check")
 {
	 quickship($o, '3');
	 echo "Order# $o, <b>$f</b> = $v (DATABASE UPDATED)<br>";
 }
//End is_numeric
}
}
//If HTTP_POST end
echo '</div>';
}

Notice this part of the code above:

quickship($o, '3');

Change the '3' to whatever status you want it changed to.

Link to comment
Share on other sites

Hi There.

 

Ive followed the instructions above and set the two number to correspond to my 2 tracking id's

 

But i get the following error.

 

1054 - Unknown column 'tracking' in 'field list'

 

select tracking from orders where orders_id = '30'

 

[TEP STOP]

 

I have had a look at order 30 and its no different to all the others.

Link to comment
Share on other sites

Thanks.

 

I think I must have been modifying the old file and not the new one.

 

Maybe if I get time i might look into adding the functionality of choosing the status.

Link to comment
Share on other sites

By all means...feel free to add functionality. That's the idea that drives open source solutions.

 

It would be easy to implement but I have limited time so can't do it myself. Look into using the defined constants such as DEFAULT_ORDERS_STATUS_ID and others.

Link to comment
Share on other sites

  • 2 weeks later...

This QuckShip Contrib is great, you would believe the amount of times I have looked for somthing to do this and each time I found one they never notified the customer..

 

Great Stuff.

 

I actually created two versions of it one to mark them as shipped an another to go from Pending to Processing, works well..

 

The only problem I have is that once you have run the despatch one it reverts back to a list of orders that are status 1 which is pending rather than 3 which is processing.

 

Can't seem to find where to define this, when I first go in to the screen I get all of my processing orders (status 3) which is fine and when I run it they move to Despatched (status 5) but as soon as the screen is refreshed it brings up all Pending Orders (status 1)

 

Any ideas?

 

 

JPL

Link to comment
Share on other sites

You did a great Job and THX!

 

I just changed a little thing in your code to make it nicer... if fact I have more than 3 status for my orders and I wanted to show what ever has not been shipped.

here is the little change around line 127

      $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and s.orders_status_id <> '3' and ot.class = 'ot_total' order by o.customers_name ASC";

 

By the way I'm using oscommerce in 4 differente language and your contrib send email in the language admin no matter in what language the customer used. I think the best way should be to ad a language_id to the order that can be recognized both in order.php page and in quickship.php page... I'm I going the right way? may be this hack allready exist! does anyone know?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...