Sorting Statuses

Is their a way to sort the order statuses?

Do you mean to sort orders by status? If so, just click the Status header on the orders.manage page.

If you mean to sort the order statuses so they will be in a specific order in the selectors then you'll have to use the 'get_status_data_post' PHP hook to sort based on your criteria.. Otherwise it just uses DB retrieval order.

If you mean to sort the order statuses so they will be in a specific order in the selectors then you'll have to use the 'get_status_data_post' PHP hook to sort based on your criteria.. Otherwise it just uses DB retrieval order.

Yup. that's what I was asking.. Just didn't know If I was missing it somewhere...

It's not a setting, it's a bit of custom code.

Ttbirnseth, there are no ways to sort it, only with the help of code modification.

Is their a way to sort the order statuses?

If you need ABC sorting, please open the app/functions/fn.common.php, find the fn_get_simple_statuses php function and replace:

. " WHERE a.type = ?s",

with

. " WHERE a.type = ?s ORDER BY description",

Unfortunately this function does not have hooks

As I said above one needs to use the get_status_data_post hook to do the sorting.

The architectural question would be: Why doesn't fn_get_simple_statuses() use fn_get_status_data() so the resulting info can utilize the hooks?

As I said above one needs to use the get_status_data_post hook to do the sorting.

The architectural question would be: Why doesn't fn_get_simple_statuses() use fn_get_status_data() so the resulting info can utilize the hooks?

Hook requested: http://forum.cs-cart.com/topic/40547-your-add-on-needs-a-new-hook-in-cs-cart-post-it-here/page-3#entry237996

Looks like it is too small function to have a hook :)

Looks like it is too small function to have a hook :)

The size of function is not a reason to skip hooks. fn_get_simple_statuses and fn_get_statuses functions have similar functionality. But one has 3 hooks and another one does not have them at all. Unfairly!

Bit them up! (Joking)

CarStickersDecals, so what kind of sorting do you need?

CarStickersDecals, so what kind of sorting do you need?

We were just wanting to sort the "Order Statuses" within the drop downs.. Just have a little organization..

We were just wanting to sort the "Order Statuses" within the drop downs.. Just have a little organization..

So you need the Position fields for each order status?

So you need the Position fields for each order status?

Yup... Not sure why its not there by default. We can sort just about everything else..

You'd have 4 steps to provide status position sorting.

1) Add a "position tinyint(3) unsigned not null default 0" column to the database ?:statuses table

2) Modify the admin areas for whatever statuses you want to set

3) Modify the fn_get_statuses() function to support the 'position' field and sort based on it (should probably be ORDER BY position, description)

4) Modify the fn_get_simple_statuses() to do the same ORDER BY clause.

#2 is the biggest pain and the one that will probably cause you the most problem downstream at upgrade time.

You can try using statuses:extra_data hook for point 2

3) Modify the fn_get_statuses() function to support the 'position' field and sort based on it (should probably be ORDER BY position, description)

I think, this point is most inconvenient. As for templates, at least you can override the whole template if it does not have hooks

As I understood what Jay was requesting was.

* Ability to set position of various statuses in the system as they are shown in selectors (not necessarily an alpha or numeric sort order on the key or value).

The normal way to set 'positions' in cs-cart is to have a 'position' column displayed in the admin and underlying support for sorting by 'position' in the database. To accomplish that would take the 4 steps listed in #17. While some things may be "inconvenient", there are proper ways to do things for both UX consistency as well as good design.

Order statuses are a perfect example of why traditional sorts won''t work for showing statuses in workflow order. The only way to make that work would be to change the names and prefix them with a numeric value so that alpha-sort would work.

Distributed order statuses are (in workflow order):

N - Incomplete

F -Failed

D - Declined

B - Backordered

O - Open

P - Processed

C - Complete

I - Canceled

As you can see, a sort on neither the key nor the value will return a proper workflow order.

Adding a position parameter is the "proper" way to do this and then it can be applied to any other status that is store in the database.