Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Highlight Old Orders


Guest

Recommended Posts

What this contrib does:

=========================

 

1) Go to Admin -> Customers -> Orders -> Change the pull down Order Status to 'Pending' -> then back to 'All Orders'. 0 (zero) orders are listed. This code fixes that.

 

2) Reverse sort the 'Pending' orders (order status 1) so that the oldest order shows up first. This helps you take care of the orders that have been sitting the longest.

 

3) If an order sits in Pending for over 24 hours, the order number becomes colored red when viewing Pending orders. Other displays are unaffected.

 

It was built and tested on 2.2 MS2. It should work on other versions with minor tweaking.

 

Downloadable at http://www.oscommerce.com/community/contributions,2685 .

Edited by jcall
Link to comment
Share on other sites

Yes, the word pending is hardcoded. It's easy to find, you can change it to whatever you've renamed "Pending" to.

 

In the next release, I'll change that so that it looks for order status 1 rather than the name "pending". I just need to add a bit to one of the existing queries to pick up the order status rather than just the order name.

 

-jared

Edited by jcall
Link to comment
Share on other sites

Yes, the word pending is hardcoded.  It's easy to find, you can change it to whatever you've renamed "Pending" to.

 

In the next release, I'll change that so that it looks for order status 1 rather than the name "pending".  I just need to add a bit to one of the existing queries to pick up the order status rather than just the order name.

 

-jared

 

would this be here?

<!-- highlight if orders are Pending status and over 2 days old -->
               <?php if ($orders['orders_status_name'] == 'Sprejeto')
                  {
                   // convert times to unix timestamp for comparison
                   $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
                   //  172800 = 2 days in the unix timestamp format
                   if ($time_since_order_placed > 172800)  {
                    echo '<font color=red>';
                    }
               }
                ?>        

 

i changed "Received" ? .. this is not pending? in original there was "Received"

Link to comment
Share on other sites

That's the one. I originally put it as "Received" in the Tips'n'Tricks area. I've changed my own statuts==1 to Received. Your change looks good.

 

Augh! I just realized what you were saying - - I didn't change the contrib to reflect the stock order status name of Pending, like I'd intended!

 

This:

=======================================
STEP 4 (Highlight aging orders in Red)
=======================================

still in catalog/admin/orders.php, just after the line following line (the one you just added):
               <td class="dataTableContent" align="center"><b>

insert the following:

<!-- highlight if orders are Pending status and over 2 days old -->
               <?php if ($orders['orders_status_name'] == 'Received')
                  {
                   // convert times to unix timestamp for comparison
                   $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
                   //  172800 = 2 days in the unix timestamp format
                   if ($time_since_order_placed > 172800)  {
                    echo '<font color=red>';
                    }
               }
                ?>      

 

Should be this:

=======================================
STEP 4 (Highlight aging orders in Red)
=======================================

still in catalog/admin/orders.php, just after the line following line (the one you just added):
               <td class="dataTableContent" align="center"><b>

insert the following:

<!-- highlight if orders are Pending status and over 2 days old -->
               <?php if ($orders['orders_status_name'] == 'Pending')
                  {
                   // convert times to unix timestamp for comparison
                   $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
                   //  172800 = 2 days in the unix timestamp format
                   if ($time_since_order_placed > 172800)  {
                    echo '<font color=red>';
                    }
               }
                ?>      

 

 

Unless, of course, you've renamed Pending like I (and you) have . . .

 

Again, I'll fix this with the order status number rather than the name in the next couple of days. Sorry for the headache.

 

-jared

Link to comment
Share on other sites

Fixed by changing this:

// begin reverse-sort Pending orders
           if ($status == 1) 
      {        $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 = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id ASC";
      }

 

to this:

// begin reverse-sort Pending orders
           if ($status == 1) 
      {        $orders_query_raw = "select o.orders_status, 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 = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id ASC";
      }

(i.e. add the o.orders_status to the beginning of the query)

 

and then change this line:

<?php if ($orders['orders_status_name'] == 'Received')

to this:

<?php if ($orders['orders_status'] == '1')

 

That should fix it. It worked for me, even after I renamed the status a couple of times. I'll upload a new copy in a few minutes.

 

-jared

Link to comment
Share on other sites

readme typo. It's 48 hours, not 24 hours. You can change it to be 24 hours easily enough, but it's currently 48 hours (and documented as such in the code).

 

Sorry if that caused any headache.

 

-jared

Link to comment
Share on other sites

readme typo.  It's 48 hours, not 24 hours.  You can change it to be 24 hours easily enough, but it's currently 48 hours (and documented as such in the code).

 

Sorry if that caused any headache.

 

-jared

 

 

no problem at all .. we all are just expecting everything to work at the moment .. not waitting 48 hours .. i'll chage it to 1 hour .. just to see it working .. then i'll change it back to 24 ...

 

thanx

Link to comment
Share on other sites

Hi jared

 

sorry but this thing is not working .. i made backup and start on new, from new readme.txt in contribution ... i changed time to 3600 not 172800 and i tried all three status (1,2,3) and none is coloring orders .. two of them are 3 days old .. and on status 2 .. no way to color them ...

 

i tried this in Firefox and in IE .. none is coloring .. where are these status numbers set in databse .. maybe i have changed numbers to any others .. but i really don't think i did that ..

Link to comment
Share on other sites

i'm back .. silly me :)

 

i added

 

$today_time = time();

 

into aplication_top.php not into orders.php .. i didn't read carefully .. but there is one thing .. red color shows up only if you select Pending orders .. it won't color them out when it displays All Orders (selected above on the right side of page)

 

anyway .. this works ..

 

could be done so it colors them also when selceted All Orders?

 

thanx

Link to comment
Share on other sites

Just change this section

<!-- highlight if orders are Pending status and over 2 days old -->
              <?php if ($orders['orders_status'] == '1')
                 {
                  // convert times to unix timestamp for comparison
                  $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
                  //  172800 = 2 days in the unix timestamp format
                  if ($time_since_order_placed > 172800)  {
                   echo '<font color=red>';
                   }
              }
               ?>

 

to this:

<!-- highlight if orders are over 2 days old -->

                         <?php                    
                   // convert times to unix timestamp for comparison
                   $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
                   //  172800 = 2 days in the unix timestamp format
                   if ($time_since_order_placed > 172800)  {
                    echo '<font color=red>';
                    }
               
                ?>

 

That did it for me.

 

-jared

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

I added the code to each of my <td class="dataTableContent"> data tables (all of them after the one Jared told us to) which contain the order to make the whole row red and stand out even more, (I am colour blind so it helped me spot it easier).

 

 

So they all start

 

<td class="dataTableContent" align="center">

<!-- highlight if orders are over 2 days old -->

<?php

// convert times to unix timestamp for comparison

$time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );

// 172800 = 2 days in the unix timestamp format

if ($time_since_order_placed > 172800) {

echo '<font color=red>';

}

?>

Link to comment
Share on other sites

  • 1 year later...

Try changing this:

if ($time_since_order_placed > 172800) {

to this:

if ($time_since_order_placed < 172800) {

 

That should highlight orders that have been placed in the last 2 days.

 

-jared

Link to comment
Share on other sites

actually Jared, what would be better would be if each row could be highlighted depending on the order_status id

 

processing = green

pending = red

 

i tried your solution but my client wants the background color highlighted and like i said above he wants the color based on the status id

Link to comment
Share on other sites

I believe that the orders_status field is already queried in that file. You'd want to do something like (this is pseudocode:

if time < 2 days {
 switch orders_status {
case 1:  echo '<font color="red">'; break;
case 2:  echo '<font color="blue">'; break:
 } // end switch
 echo '</font>':
} // end time-based status-sensitive coloring

 

You can find out the number for order status in Admin by clicking on each order status (under localization IIRC) and watching the status= variable change in the URL.

 

-jared

Edited by jcall
Link to comment
Share on other sites

Whole thing works great for me !!

 

I added another bit of code to highlight orders that have been status "on its way" for more than four days (easy to identify which orders can be updated to delivered and/or tracked down if the customer has not recieved it

 

// begin reverse-sort Pending orders
		if ($status == 1) 
   {		$orders_query_raw = "select o.orders_status, 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 = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id ASC";
   }
   else
		if ($status == 5) 
   {		$orders_query_raw = "select o.orders_status, 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 = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id ASC";
   }
// end reverse-sort Pending orders

 

<?php
// highlight if orders are Pending status and over 2 days old -->
 if ($orders['orders_status'] == '1') {
 // convert times to unix timestamp for comparison
 $time_since_order_placed = ($today_time - strtotime($orders['date_purchased']) );
 //  172800 = 2 days in the unix timestamp format
 if ($time_since_order_placed > 172800)  {
 echo '<font color=red>';
										 }
									  }
// highlight if orders are On its way  status and over 4 days old -->
 if ($orders['orders_status'] == '5'){
  // convert times to unix timestamp for comparison
  $time_since_order_updated = ($today_time - strtotime($orders['last_modified']) );
  //  345600= 4 days in the unix timestamp format
  if ($time_since_order_updated > 345600)  {
  echo '<font color=green>';
										}
								   } 
echo $orders['orders_id']; 
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...