View Single Post
Old 10-05-2012, 05:34 AM
notgrass notgrass is offline

Advanced Member
Join Date: Dec 2011
Location: Tennessee
Posts: 33

Default 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:

[X-Cart Directory]/admin/giftcerts.php

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";
X-Cart v4.6.5
Reply With Quote