Change Sort Order for Gift Certificates
Our business does not sell gift certificates. We give them away as bonuses to our customers. Since these certificates do not have an order ID attached, the default sort order in the Gift Certificates module made no sense, and I had to hunt through the list to change Pending certificates to Active.
I modified the SQL query of the giftcerts table to sort the list of certificates as I preferred. In this file:
find the line--
$query = "SELECT *, add_date+'" . $config["Appearance"]["timezone_offset"] . "' as add_date FROM $sql_tbl[giftcerts] WHERE 1 $expired_condition";
After $expired_condition and before the closing "; you can add an ORDER BY modifier. I used "ORDER BY status DESC, debit" to group all of the Pending certificates at the top of the list and sort the Active certificates by amount remaining so I can clear out the empty ones. Like this:
$query = "SELECT *, add_date+'" . $config["Appearance"]["timezone_offset"] . "' as add_date FROM $sql_tbl[giftcerts] WHERE 1 $expired_condition ORDER BY status DESC, debit";