If you want to add a new ordering to orders just use “pre_get_orders” function in fn.cart.php.
use this code in your function in func.php
<br />
$sortings['anyname'] = "?:orders.mytable";<br />
```<br />
<br />
manage_header.pst.tpl<br />
<br />
```php
<br />
<br />
<a class="cm-ajax" href="{"`$c_url`&sort_by=anyname&sort_order=`$search.sort_order_rev`"|fn_url}" data-ca-target-id={$rev}>{__("title")}{if $search.sort_by == "anyname"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}</a><br />
<br />
I shared this topic but I have a problem. There is no problem at localhost, but when I upload it to the server there is problem. I click my link (anyname), orders should be ordered by the mytable, but they are ordered by order date. It happens only at live website. It doesn't happen at localhost. I couldn solve it.
func.php
function fn_myaddon_pre_get_orders($params, $fields, $sortings, $get_totals, $lang_code) {
$sortings['anyname'] = "?:orders.mytable";
}
And you did clear both the registry cache (cc) and the template cache (ctpl) on your production site, correct?
hello. I have found my mistake. Correct usage should like this:
function fn_myaddon_pre_get_orders(&$params, &$fields, &$sortings, &$get_totals, &$lang_code) {
$sortings['anyname'] = "?:orders.mytable";
return true;
}
hi ooaykac,
the problem was in the first line where Hook-function is declared:
function fn_myaddon_pre_get_orders(&$params, &$fields, &$sortings, &$get_totals, &$lang_code) {
in PHP 5.4 and higher if you don't use sign “&” before variable names in function declaration, they will not be saved after function is executed.
The line with “return” is not need for Hook functions in CS-Cart and may be skipped.
best regards,
WSA team
[quote name='Damir (WSA-team)' timestamp='1431335884' post='213918']
hi ooaykac,
the problem was in the first line where Hook-function is declared:
function fn_myaddon_pre_get_orders(&$params, &$fields, &$sortings, &$get_totals, &$lang_code) {
in PHP 5.4 and higher if you don't use sign “&” before variable names in function declaration, they will not be saved after function is executed.
The line with “return” is not need for Hook functions in CS-Cart and may be skipped.
best regards,
WSA team
[/quote]
Thanks Damir.
[quote name=‘Damir (WSA-team)’ timestamp=‘1431356622’ post=‘213979’]
you’re welcome! 
[/quote]
Should I use “&” sign for all my PHP hooks?
yes, it is recommended to do so
Not necessarily. You should use “pass by reference” (php & syntax) when you want changes to that variable reflected back in the caller or you want to reduce the stack size of the parameters being passed (I.e. with & it passes a pointer (address) of the data and without passes a copy of the data). But for small values and/or items you want to massage in your own code without affecting the parent you may want to use “pass by value” syntax (no & in PHP).
It all depends on what you are doing with the parameters being passed to the hook function and what 'effect' you want to cause in the caller.