Jump to content

sort orders by status


Guest iiluxury

Recommended Posts

Guest iiluxury

Any mod allow me to sort orders by status. cos I am getting too many pending orders.

I dont want see them. I want to see processing orders in a screen. thanks.

Link to comment
Share on other sites

go to /admin/orders/ and edit index.php

search for:

	// query database

	if(isset($_GET['page'])){

		$page = $_GET['page'];

	} else {

		$page = 0;

	}

	

	$ordersPerPage = 25;

	

	$query = "SELECT ".$glob['dbprefix']."CubeCart_customer.customer_id, status, cart_order_id, time, title, firstName, lastName, ip, prod_total, ".$glob['dbprefix']."CubeCart_customer.email FROM ".$glob['dbprefix']."CubeCart_order_sum INNER JOIN ".$glob['dbprefix']."CubeCart_customer ON ".$glob['dbprefix']."CubeCart_order_sum.customer_id = ".$glob['dbprefix']."CubeCart_customer.customer_id ".$sqlQuery." ORDER BY time DESC";

	

	$results = $db->select($query, $ordersPerPage, $page);

	$numrows = $db->numrows($query);

	$pagination = $db->paginate($numrows, $ordersPerPage, $page, "page");



?>




and replace it with this:
	// query database

	if(isset($_GET['page'])){

		$page = $_GET['page'];

	} else {

		$page = 0;

	}

	

	$ordersPerPage = 25;

	

	$query = "SELECT ".$glob['dbprefix']."CubeCart_customer.customer_id, status, cart_order_id, time, title, firstName, lastName, ip, prod_total, ".$glob['dbprefix']."CubeCart_customer.email FROM ".$glob['dbprefix']."CubeCart_order_sum INNER JOIN ".$glob['dbprefix']."CubeCart_customer ON ".$glob['dbprefix']."CubeCart_order_sum.customer_id = ".$glob['dbprefix']."CubeCart_customer.customer_id ".$sqlQuery." ORDER BY status DESC";

	

	$results = $db->select($query, $ordersPerPage, $page);

	$numrows = $db->numrows($query);

	$pagination = $db->paginate($numrows, $ordersPerPage, $page, "page");



?>

although i dont know if you have to order it ASC or DESC, just try it out :)

Link to comment
Share on other sites

  • 3 months later...
Guest Captain Bags

Thanks, peppy - I wasn't sure where to make the ORDER BY change.

The trouble is that it sorts on the status ID: 1 = Pending, 2 = Processing, 3 = Completed etc.

That simple change either shows all Pending first (ASC) or all Completed first (DESC).

I need to see Processing first, followed by Pending, and then all the rest.

My SQL coding is very rusty but I think it needs a UNION

Anybody up to the challenge? :blink:

Link to comment
Share on other sites

  • 1 month later...
Guest murkington

I'm also very interested in this as well, anyone know how to do this? I'm a novice compared to most of you guys on here.

Thanks, peppy - I wasn't sure where to make the ORDER BY change.

The trouble is that it sorts on the status ID: 1 = Pending, 2 = Processing, 3 = Completed etc.

That simple change either shows all Pending first (ASC) or all Completed first (DESC).

I need to see Processing first, followed by Pending, and then all the rest.

My SQL coding is very rusty but I think it needs a UNION

Anybody up to the challenge? :sourcerer:

Link to comment
Share on other sites

  • 3 months later...
Guest craiga

I'm also very interested in this as well, anyone know how to do this? I'm a novice compared to most of you guys on here.

Thanks, peppy - I wasn't sure where to make the ORDER BY change.

The trouble is that it sorts on the status ID: 1 = Pending, 2 = Processing, 3 = Completed etc.

That simple change either shows all Pending first (ASC) or all Completed first (DESC).

I need to see Processing first, followed by Pending, and then all the rest.

My SQL coding is very rusty but I think it needs a UNION

Anybody up to the challenge? :)

Perhaps use: order by field(status, 3, 1, 2) desc

Link to comment
Share on other sites

I (with help of a friend to get the syntax right), did a dropdown for sorting order status...only problem is has if it breaks if you have more than one page - which personally, I switched $ordersperpage = 2500; so I could view them all on one page anyway. This also sorts your order by date - newest on top, oldest on bottom which is how I like it. Of course you can change it.

In admin/orders/index.php ....

Find about line 84:

	$ordersPerPage = 25;




Add after it:






if (isset($_GET['updatestatus'])) { 

 

 if (($_GET['updatestatus']) == "now") {

 

 $newstatus=@strip_tags($_POST['newstatus']);






Right after this, is the original $query statement:




	$query = "SELECT ".$glob['dbprefix']."CubeCart_customer.customer_id, status, cart_order_id, time, title, firstName, lastName, ip, prod_total, ".$glob['dbprefix']."CubeCart_customer.email FROM ".$glob['dbprefix']."CubeCart_order_sum INNER JOIN ".$glob['dbprefix']."CubeCart_customer ON ".$glob['dbprefix']."CubeCart_order_sum.customer_id = ".$glob['dbprefix']."CubeCart_customer.customer_id ".$sqlQuery." ORDER BY status ASC";




Replace it with:




	 $query = "SELECT ".$glob['dbprefix']."CubeCart_customer.customer_id, status, cart_order_id, time, title, firstName, lastName, ip, prod_total, ".$glob['dbprefix']."CubeCart_customer.email FROM ".$glob['dbprefix']."CubeCart_order_sum INNER JOIN ".$glob['dbprefix']."CubeCart_customer ON ".$glob['dbprefix']."CubeCart_order_sum.customer_id = ".$glob['dbprefix']."CubeCart_customer.customer_id  ".$sqlQuery." where status=".$newstatus." ORDER BY time DESC"; 

 

 }

  } else {

	 $query = "SELECT ".$glob['dbprefix']."CubeCart_customer.customer_id, status, cart_order_id, time, title, firstName, lastName, ip, prod_total, ".$glob['dbprefix']."CubeCart_customer.email FROM ".$glob['dbprefix']."CubeCart_order_sum INNER JOIN ".$glob['dbprefix']."CubeCart_customer ON ".$glob['dbprefix']."CubeCart_order_sum.customer_id = ".$glob['dbprefix']."CubeCart_customer.customer_id  ".$sqlQuery." ORDER BY time DESC"; 

 }






Find about line 103:




<p class="pageTitle"><?php echo $lang['admin']['orders']['orders']; ?></p>




after it add (edit as needed for your statuses:




<form action="index.php?updatestatus=now" method="post">

 <select name="newstatus">

 <option value="1">Pending</option>

 <option value="2">Awaiting Shipment</option>

 <option value="3">Complete</option>

 <option value="4">Declined</option>

 <option value="5">On Hold</option>

 <option value="6">Cancelled</option>

 <option value="7">Partial Order Shipped</option>

 </select>

   <input type="submit" name="submit" value="view" />

</form>

That's it. Just save and upload the file.

Link to comment
Share on other sites

  • 3 months later...

Thanks a lot for this modification... I've been looking for that since weeks.

Slightly different need now is 'how to know which product is a best seller'.

Not the one which is mostly seen on the store, but, based on sales records, how to order best sales ?

Anyhow, thanks for this orders sorts mod...

Fabien, for forcemajeure.com

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
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...