Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Sort Option Type Names

Sorting Option Type Names in Table Heading

There is no way in the standard Cartweaver code to sort the option type names used in the table heading when you have a multiple-option product and have a display type of "Tables" or more than 2 options on a product. To allow a sort field to be used, first add the sort field to the tbl_list_optiontypes table (optiontype_Sort tinyint) and populate it with data. Then add this small modification to the CWFunProductOptions.php file:

Code was:

/* If we have more than 1 option, get our option information set for display */
if($displayType == "Tables") {
  $optionNames = arrayKeyToArray($rsCWAllOptions, "optiontype_Name");
  $numOptions = count($optionNames);
  $optionArray = array();
  cwDebugger($optionNames);
}

New code:

/* If we have more than 1 option, get our option information set for display */
if($displayType == "Tables") {
  $optionNames = arrayKeyToArray($rsCWAllOptions, "optiontype_Name");
  $numOptions = count($optionNames);
  $optionArray = array();
  cwDebugger($optionNames);

  /* MODIFICATION FOR SORTING */
  $optionNamesTemp = array();
  $query_rsCWGetOptionSort = "SELECT optiontype_Name, optiontype_Sort
  FROM tbl_list_optiontypes
  ORDER BY optiontype_Sort";
  $rsCWGetOptionSort = $cartweaver->db->executeQuery($query_rsCWGetOptionSort);
  $rsCWGetOptionSort_recordCount = $cartweaver->db->recordCount;
  $row_rsCWGetOptionSort = $cartweaver->db->db_fetch_assoc($rsCWGetOptionSort);
  do {
    if(in_array($row_rsCWGetOptionSort["optiontype_Name"], $optionNames)) {
      array_push($optionNamesTemp, $row_rsCWGetOptionSort["optiontype_Name"]);
    }
  } while ($row_rsCWGetOptionSort = $cartweaver->db->db_fetch_assoc($rsCWGetOptionSort));
  $optionNames = $optionNamesTemp;
}

Back to Cartweaver PHP FAQ, code changes, and samples

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2025 Tom Muck | Dreamweaver Extensions