Change Order Status Ordering

I have a client that had me change the order statuses around and rename them. They only use 3 of the statuses and would like those 3 to be at the top of the list.



For the life of me, I can't figure out how to change the order of the statuses in the status popup box. Has anyone done anything like this?



Thanks,



Brandon

I can say you only that the sorting is defined in cscart_status_descriptions sort by status a b c … and so soon

and if is only the controller/status.php responsible i can not say :) ( ORDER BY ?:status_descriptions.description )

Hi [color=#282828][font=arial, verdana, tahoma, sans-serif]Brandon,[/font][/color]



Firstly you need to add “position” field in ?:statuses table:


ALTER TABLE `?:statuses` ADD `position` smallint(5) unsigned NOT NULL DEFAULT '0';


It field will be used for ordering statuses in the list.

Secondly you need go to the $DIR_ROOT/controllers/admin/statuses.php file and replace


ORDER BY ?:status_descriptions.description


in


$statuses = db_get_hash_array("SELECT ?:statuses.*, ?:status_descriptions.* FROM ?:statuses LEFT JOIN ?:status_descriptions ON ?:statuses.status = ?:status_descriptions.status AND ?:statuses.type = ?:status_descriptions.type AND ?:status_descriptions.lang_code = ?s AND ?:statuses.type = ?s ORDER BY ?:status_descriptions.description", 'status', DESCR_SL, $_REQUEST['type']);


by


ORDER BY ?:statuses.postition DESC


Thirdly, go to the $DIR_ROOT/core/fn.cart.php file, find function fn_get_statuses and add


ORDER BY a.position DESC


after


WHERE a.type = ?s


in


$statuses = db_get_hash_single_array("SELECT a.status, b.description FROM ?:statuses as a LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s WHERE a.type = ?s ORDER BY a.position DESC", array('status', 'description'), $lang_code, $type);


and


$statuses = db_get_hash_array("SELECT a.status, b.description FROM ?:statuses as a LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s WHERE a.type = ?s ORDER BY a.position DESC", 'status', $lang_code, $type);


lines of code.





Now you can edit values in “position” field and statuses will change their order.

Note, order statuses have type 'O'.

[quote name='h694616' timestamp='1337679993' post='136982']

Secondly you need go to the $DIR_ROOT/controllers/admin/statuses.php file and replace


ORDER BY ?:status_descriptions.description


in


$statuses = db_get_hash_array("SELECT ?:statuses.*, ?:status_descriptions.* FROM ?:statuses LEFT JOIN ?:status_descriptions ON ?:statuses.status = ?:status_descriptions.status AND ?:statuses.type = ?:status_descriptions.type AND ?:status_descriptions.lang_code = ?s AND ?:statuses.type = ?s ORDER BY ?:status_descriptions.description", 'status', DESCR_SL, $_REQUEST['type']);


by


ORDER BY ?:statuses.postition DESC




[/quote]



I'm sorry



by


ORDER BY ?:statuses.postition DESC


by


ORDER BY ?:statuses.position DESC

Sweet, that is awesome. That definitely made it so that I can set an order and now the statuses come up exactly the way I want.



Thank you very much for sharing that on here.



Brandon

Hello,

can someone tell us how we implement that in cs-cart version 4.1.x ?



thank you

[quote name='dataspotgr' timestamp='1417428447' post='198443']

Hello,

can someone tell us how we implement that in cs-cart version 4.1.x ?



thank you

[/quote]



Follow this instruction:


  1. Execute sql code:


ALTER TABLE `?:statuses` ADD `position` SMALLINT( 5 ) UNSIGNED NOT NULL ;



2. Add necessary positions for statuses, for ex:



UPDATE `?:statuses` SET `position` = '10' WHERE `type` = 'O' AND status = 'P';
UPDATE `?:statuses` SET `position` = '20' WHERE `type` = 'O' AND status = 'C';
UPDATE `?:statuses` SET `position` = '30' WHERE `type` = 'O' AND status = 'O';
UPDATE `?:statuses` SET `position` = '40' WHERE `type` = 'O' AND status = 'F';
UPDATE `?:statuses` SET `position` = '50' WHERE `type` = 'O' AND status = 'D';
UPDATE `?:statuses` SET `position` = '60' WHERE `type` = 'O' AND status = 'B';
UPDATE `?:statuses` SET `position` = '70' WHERE `type` = 'O' AND status = 'I';




3. Go to [CS-Cart root dir]/app/functions/fn.common.php and find “function fn_get_simple_statuses”



change this code inside function:



$statuses = db_get_hash_single_array(
"SELECT a.status, b.description"
. " FROM ?:statuses as a"
. " LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s"
. " WHERE a.type = ?s",
array('status', 'description'),
$lang_code, $type
);




to this:



$statuses = db_get_hash_single_array(
"SELECT a.status, b.description"
. " FROM ?:statuses as a"
. " LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s"
. " WHERE a.type = ?s ORDER by position",
array('status', 'description'),
$lang_code, $type
);




That's all.



[color=#282828][font=arial, verdana, tahoma, sans-serif]Best regards,[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Leonid[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Chief Technology Officer of CSExperts [/font][/color]

Thank you very much! It worked perfectly!!

[quote name='dataspotgr' timestamp='1417790615' post='198855']

Thank you very much! It worked perfectly!!

[/quote]



You're welcome! I am glad that this information is useful for you.



[color=#282828][font=arial, verdana, tahoma, sans-serif]Best regards,[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Leonid[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Chief Technology Officer of CSExperts [/font][/color]