/** * Return all subcategory IDs * * @param $aSubcategories * @param $nParentId */ function oos_get_subcategories(&$aSubcategories, $nParentId = 0) { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $categoriestable = $oostable['categories']; $query = "SELECT categories_id\n FROM {$categoriestable}\n WHERE parent_id = '" . intval($nParentId) . "'"; $result =& $dbconn->Execute($query); while ($subcategories = $result->fields) { $aSubcategories[count($aSubcategories)] = $subcategories['categories_id']; if ($subcategories['categories_id'] != $nParentId) { oos_get_subcategories($aSubcategories, $subcategories['categories_id']); } // Move that ADOdb pointer! $result->MoveNext(); } // Close result set $result->Close(); }
$select_str .= ", SUM(tr.tax_rate) AS tax_rate "; } $from_str = "FROM " . $oostable['products'] . " p LEFT JOIN\n " . $oostable['manufacturers'] . " m using(manufacturers_id) LEFT JOIN\n " . $oostable['specials'] . " s ON p.products_id = s.products_id"; if ($_SESSION['member']->group['show_price_tax'] == 1 && (isset($_GET['pfrom']) && oos_is_not_null($_GET['pfrom']) || isset($_GET['pto']) && oos_is_not_null($_GET['pto']))) { if (!isset($_SESSION['customer_country_id'])) { $_SESSION['customer_country_id'] = STORE_COUNTRY; $_SESSION['customer_zone_id'] = STORE_ZONE; } $from_str .= " LEFT JOIN\n " . $oostable['tax_rates'] . " tr\n ON p.products_tax_class_id = tr.tax_class_id LEFT JOIN\n " . $oostable['zones_to_geo_zones'] . " gz\n ON tr.tax_zone_id = gz.geo_zone_id AND\n (gz.zone_country_id is null OR\n gz.zone_country_id = '0' OR\n gz.zone_country_id = '" . intval($_SESSION['customer_country_id']) . "') AND\n (gz.zone_id is null OR\n gz.zone_id = '0' OR\n gz.zone_id = '" . intval($_SESSION['customer_zone_id']) . "')"; } $from_str .= ", " . $oostable['products_description'] . " pd, " . $oostable['categories'] . " c, " . $oostable['products_to_categories'] . " p2c"; $where_str = " WHERE\n p.products_status >= '1' AND\n p.products_id = pd.products_id AND\n pd.products_languages_id = '" . intval($nLanguageID) . "' AND\n p.products_id = p2c.products_id AND\n p2c.categories_id = c.categories_id "; if (isset($_GET['categories_id']) && oos_is_not_null($_GET['categories_id'])) { if ($_GET['inc_subcat'] == '1') { $subcategories_array = array(); oos_get_subcategories($subcategories_array, $_GET['categories_id']); $where_str .= " AND\n p2c.products_id = p.products_id AND\n p2c.products_id = pd.products_id AND\n (p2c.categories_id = '" . intval($_GET['categories_id']) . "'"; for ($i = 0, $n = count($subcategories_array); $i < $n; $i++) { $where_str .= " OR p2c.categories_id = '" . intval($subcategories_array[$i]) . "'"; } $where_str .= ")"; } else { $where_str .= " AND\n p2c.products_id = p.products_id AND\n p2c.products_id = pd.products_id AND\n pd.products_languages_id = '" . intval($nLanguageID) . "' AND\n p2c.categories_id = '" . intval($_GET['categories_id']) . "'"; } } if (isset($_GET['manufacturers_id']) && oos_is_not_null($_GET['manufacturers_id'])) { $manufacturers_id = intval($_GET['manufacturers_id']); $where_str .= " AND m.manufacturers_id = '" . intval($manufacturers_id) . "'"; } if (isset($_GET['keywords']) && oos_is_not_null($_GET['keywords'])) { if (oos_parse_search_string(stripslashes($_GET['keywords']), $search_keywords)) {
} $from_str .= ", " . $oostable['products_description'] . " pd, " . $oostable['categories'] . " c, " . $oostable['products_to_categories'] . " p2c"; $where_str = " WHERE p.products_status >= '1' AND p.products_id = pd.products_id AND pd.products_languages_id = '" . intval($nLanguageID) . "' AND p.products_id = p2c.products_id AND p2c.categories_id = c.categories_id "; if (isset($_GET['categories_id']) && !empty($_GET['categories_id'])) { $nCategoriesID = (int)$_GET['categories_id']; if (isset($_GET['inc_subcat']) && ($_GET['inc_subcat'] == '1')) { $aSsubcategories = array(); oos_get_subcategories($aSsubcategories, $_GET['categories_id']); $where_str .= " AND p2c.products_id = p.products_id AND p2c.products_id = pd.products_id AND (p2c.categories_id = '" . intval($nCategoriesID) . "'"; $nCountSubcategories = count($aSsubcategories); for ($i=0, $n=$nCountSubcategories; $i<$n; $i++ ) { $where_str .= " OR p2c.categories_id = '" . intval($aSsubcategories[$i]) . "'"; } $where_str .= ")"; } else { $where_str .= " AND p2c.products_id = p.products_id AND p2c.products_id = pd.products_id AND pd.products_languages_id = '" . intval($nLanguageID) . "' AND p2c.categories_id = '" . intval($_GET['categories_id']) . "'";