Status Change History

Hello ppl,



I want to know if there is somewhere where i can see the status changes of my orders. For example i change it from open to awaiting payment and then to processing, show it something like “Open > Awaiting Payment > Processing” or anything similar. Also cs-cart does not use any cache validator? If not anyone know an addon or a way to enable cache validation on css, js files?



Thanks in advance,

Artemis

There is no history of order statuses in the standard cart.



What do you mean by a cache validator for js/css? Normally a browser makes the request and the store responds with the last-modification time and leaves whether to download or use the browser's cached version up to the browser.

I'm working on this add-on actually. Practically finished it but now I'm rethinking the data logic.



@tbirnseth: Would you suggest creating a new table to store the status history or

reusing the function where the logs already store it? I actually just finished creating

it using new table but I'm rethinking if it would be a good idea to change it to use

logs, but since they get cleared sometimes it might be a better idea to use a new table.

What do you think?

I would keep it in a separate table. Whether you do it a row per change or a serialized array keyed on the timestamp is more a matter of preference and whether you plan to display it on request or all the time.

@tbinseth: What advantage do I have with a serial array you think? I have not used them much until CS Cart. So I don't really understand them. Right now I have just one table and it will be accessed by customers on the order detail page, and in the admin as a new tab under order pages (just like the add ons tab is).



Also do you know where how I can get the order_id in my function hook. I have created my function hook

for my add on and i know its working because changed and order status in cs-cart and had my hook set to send me a test email and i did get it but im not sure how to get the order data in my function. this is my function hook but when i use order_id it shows the status code so something is wrong. any ideas?





function fn_order_history_change_order_status($order_id, $status_to, $status_from = '', $force_notification = array(), $place_order = false)

{

To get order data from an order_id use fn_get_order_info($order_id);



Whether to use a row per status or a row per order is a design choice. For simplicity, I would probably store all the status changes in an array indexed by timestamp with the value being the status being changed to. So you'd end up with something that looks like:


$order_status_info = array( => 'O', => 'P', => 'C'....);


You could then just store this in a table with 2 columns (order_id, status_data) where 'status_data' is a text field and is stored via:


$data = serialize($order_status_info);


And when you read it from your table you'd read the data into an array from the db and then:


$data = db_get_field("SELECT * FROM ?:order_status_history WHERE order_id=?i", $order_id);
if( !empty($data['status_data']) )
$data['status_data'] = unserialize($data['status_data']);
return $data;

Thanks I'll give t a try. But no suggestion on how

To get the order I'd into my function? If I explained

Correctly when I change am order status my function

Is being called but I need the order id accessible

In my function to e able to know which order I am working

With.



As fr serialization the only reason is for simplicity

Of the database less tables and fields, right?

In case anyone comes across this post. I finally figured out the order_id. apparently the fn_change_order_status has the following variables available to it $status_to, $status_from, $order_info, $force_notification, $order_statuses





All I had to do was use $order_info[‘order_id’] to output the order_id I required. All is well now. :)