/** * This method creates and returns front-end output for original, non-flyout-enabled category menus * * @return string */ protected function _generateClassicOutput () { $output = ""; $categories = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('RootCategories'); if (!isset($categories[0])) { return $output; } foreach($categories[0] as $rootCat) { // If we don't have permission to view this category then skip if(!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) { continue; } $GLOBALS['SubCategoryList'] = $this->_getSubCategory($categories, $rootCat['categoryid']); $GLOBALS['LastChildClass']=''; $GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']); $GLOBALS['CategoryLink'] = CatLink($rootCat['categoryid'], $rootCat['catname'], true); // @todo ul here is hacky but front end templates are limited, fix this when possible $output .= '<ul>' . $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList") . '</ul>'; } return $output; }
public function GetCategoryOptionsProduct($SelectedCats = 0, $Container = "<option %s value='%d'>%s</option>", $Sel = "selected=\"selected\"", $Divider = "- ", $IncludeEmpty = true, $visible = '', $visibleCats = array()) { // Get a list of categories as <option> tags $cats = ''; // Make sure $SelectedCats is an array if (!is_array($SelectedCats)) { $SelectedCats = array(); } if (empty($SelectedCats) || in_array("0", $SelectedCats)) { $sel = 'selected="selected"'; } else { $sel = ""; } // Do we include the no parent category item in the list ? if ($IncludeEmpty) { $cats = sprintf("<option %s value='0'>-- %s --</option>\n", $sel, GetLang("NoParent")); } // Get a formatted list of all the categories in the system $categories = $this->getCats($Divider, 0, '', $visible); // Work out which cats we want to keep in the list $this->getCatsInfo($visible); foreach ($categories as $cid => $cname) { // If we're on the front end of the store, do we have permission to view this category? if (!defined('ISC_ADMIN_CP') && !CustomerGroupHasAccessToCategory($cid)) { continue; } else { if (!empty($visibleCats) && !in_array($cid, $visibleCats)) { continue; } } if (in_array($cid, $SelectedCats)) { $s = $Sel; } else { $s = ''; } $cats .= sprintf($Container, $s, $cid, $cid, $cname); } return $cats; }
public function SetCategoryData() { // Retrieve the query string variables. Can't use the $_GET array // because of SEO friendly links in the URL SetPGQVariablesManually(); // Grab the page sort details if (isset($_REQUEST['category'])) { $GLOBALS['CategoryPath'] = isc_html_escape($_REQUEST['category']); $path = explode("/", $_REQUEST['category']); } else { $GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']); $path = $GLOBALS['PathInfo']; array_shift($path); } $this->SetSort(); $this->SetCatPath($path); $arrCats = $this->_catpath; for ($i = 0; $i < count($arrCats); $i++) { $arrCats[$i] = MakeURLNormal($arrCats[$i]); } if (!isset($arrCats[0])) { $arrCats[0] = ''; } // The first category *MUST* have a parent ID of 0 or it's invalid $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]categories\n\t\t\t\tWHERE LOWER(catname) ='" . $GLOBALS['ISC_CLASS_DB']->Quote($arrCats[0]) . "' AND catparentid=0\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $this->SetTrail(array($row['categoryid'], $row['catname'])); $this->SetId($row['categoryid']); $this->SetName($row['catname']); $this->SetDesc($row['catdesc']); $this->SetLayoutFile($row['catlayoutfile']); $this->SetCatPageTitle($row['catpagetitle']); $this->SetMetaKeywords($row['catmetakeywords']); $this->SetMetaDesc($row['catmetadesc']); // The root category is valid, try and loop through each category to find the ID of the last category in the set if (count($arrCats) > 1) { $parentCat = $row['categoryid']; for ($i = 1; $i < count($arrCats); $i++) { if (!$arrCats[$i]) { continue; } $query = "\n\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\tFROM [|PREFIX|]categories\n\t\t\t\t\t\t\tWHERE LOWER(catname) ='" . $GLOBALS['ISC_CLASS_DB']->Quote($arrCats[$i]) . "' AND catparentid='" . (int) $parentCat . "'\n\t\t\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $parentCat = $row['categoryid']; $this->Data = $row; $this->SetTrail(array($row['categoryid'], $row['catname'])); $this->SetId($row['categoryid']); $this->SetName($row['catname']); $this->SetDesc($row['catdesc']); $this->SetLayoutFile($row['catlayoutfile']); $this->SetCatPageTitle($row['catpagetitle']); $this->SetMetaKeywords($row['catmetakeywords']); $this->SetMetaDesc($row['catmetadesc']); } else { continue; } } $this->SetId($parentCat); } else { $this->Data = $row; $this->SetId($row['categoryid']); $this->SetName($row['catname']); $this->SetDesc($row['catdesc']); $this->SetCatPageTitle($row['catpagetitle']); $this->SetMetaKeywords($row['catmetakeywords']); $this->SetMetaDesc($row['catmetadesc']); } } else { $this->Data = $row; $this->SetId(0); $this->SetName(""); $this->SetDesc(""); } if (!$this->_catid) { $GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404'); $GLOBALS['ISC_CLASS_404']->HandlePage(); exit; } // Do we have permission to access this category? if (!CustomerGroupHasAccessToCategory($this->_catid)) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $GLOBALS['CatTrail'] = $this->GetTrail(); // Find the number of products in the category $this->loadCats = $this->GetId(); // This product should show products from this category, but if there are none // show them from any child categories too if (GetConfig('CategoryListingMode') == 'emptychildren') { // Load up how many products there are in the current category, if none, load from children too $this->SetNumProducts(); if ($this->_catnumproducts == 0) { $this->loadCats = trim(implode(',', $this->GetChildCategories()), ','); $this->loadCats = rtrim($this->GetId() . "," . $this->loadCats, ','); } } else { if (GetConfig('CategoryListingMode') == 'children') { $cats = $this->GetChildCategories(); $cats[] = $this->GetId(); $this->loadCats = trim(implode(',', array_unique($cats)), ','); } } $this->SetNumProducts(); // Setup paging details $this->SetPage(); $this->SetStart(); $this->SetNumPages(); // Load the products for the categories page $this->LoadProductsForPage(); }
public function SetCategoryData() { // Retrieve the query string variables. Can't use the $_GET array // because of SEO friendly links in the URL SetPGQVariablesManually(); // Grab the page sort details if (isset($_REQUEST['category'])) { $GLOBALS['CategoryPath'] = isc_html_escape($_REQUEST['category']); $path = explode("/", $_REQUEST['category']); } else { $GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']); $path = $GLOBALS['PathInfo']; array_shift($path); } $this->SetSort(); $this->SetCatPath($path); $arrCats = $this->_catpath; for ($i = 0; $i < count($arrCats); $i++) { $arrCats[$i] = MakeURLNormal($arrCats[$i]); } if (!isset($arrCats[0])) { $arrCats[0] = ''; } // The first category *MUST* have a parent ID of 0 or it's invalid $parentCat = 0; // Because of the way SEO friendly links work at the moment, we need to loop through // the category path to check each level is valid. Ideally we'd store the built category // URL in the database and check based on that. for($i = 0; $i < count($arrCats); ++$i) { if(empty($arrCats[$i])) { continue; } $query = " SELECT * FROM [|PREFIX|]categories WHERE catname = '".$GLOBALS['ISC_CLASS_DB']->quote($arrCats[$i])."' AND catparentid = '".(int)$parentCat."' AND catvisible = 1 "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); $category = $GLOBALS['ISC_CLASS_DB']->fetch($result); // Supplied category could not be found. They've followed an incorrect link so show the 404 page. if(!$category) { $GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404'); $GLOBALS['ISC_CLASS_404']->HandlePage(); exit; } // Add this category to the breadcrumb/trail $this->SetTrail(array($category['categoryid'], $category['catname'])); $parentCat = $category['categoryid']; } if (!empty($category)) { // $category contains the details of the actual category we're viewing $this->Data = $category; $this->SetId($category['categoryid']); $this->SetName($category['catname']); $this->SetDesc($category['catdesc']); $this->SetLayoutFile($category['catlayoutfile']); $this->SetCatPageTitle($category['catpagetitle']); $this->SetMetaKeywords($category['catmetakeywords']); $this->SetMetaDesc($category['catmetadesc']); $this->SetSearchKeywords($category['catsearchkeywords']); $this->SetEnableOptimizer($category['cat_enable_optimizer']); } else { // Reached /categories/ directly with no additional path. // This is the root category } // Do we have permission to access this category? if(!CustomerGroupHasAccessToCategory($this->_catid)) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $GLOBALS['CatTrail'] = $this->GetTrail(); // Find the number of products in the category $this->loadCats = $this->GetId(); // This product should show products from this category, but if there are none // show them from any child categories too if(GetConfig('CategoryListingMode') == 'emptychildren') { // Load up how many products there are in the current category, if none, load from children too $this->SetNumProducts(); if($this->_catnumproducts == 0) { $cats = $this->GetChildCategories(); // Add in the current category too- which helps out shop by price etc $cats[] = $this->getId(); $group = GetClass('ISC_CUSTOMER')->GetCustomerGroup(); if(is_array($group) && $group['categoryaccesstype'] == 'specific') { $cats = array_intersect($cats, $group['accesscategories']); } $this->loadCats = trim(implode(',', array_unique($cats)), ','); } } // Otherwise, this category shows products from itself + children else if(GetConfig('CategoryListingMode') == 'children') { $cats = $this->GetChildCategories(); $cats[] = $this->GetId(); $group = GetClass('ISC_CUSTOMER')->GetCustomerGroup(); if(is_array($group) && $group['categoryaccesstype'] == 'specific') { $cats = array_intersect($cats, $group['accesscategories']); } $this->loadCats = trim(implode(',', array_unique($cats)), ','); } $this->SetNumProducts(); // Setup paging details $this->SetPage(); $this->SetStart(); $this->SetNumPages(); // Load the products for the categories page $this->LoadProductsForPage(); }
/** * get the html for sub category list * * @param array $categories the array of all categories in a tree structure * @param int $parentCatId the parent category ID of the sub category list * * return string the html of the sub category list */ function GetSubCategory($categories, $parentCatId) { $output = ''; //if there is sub category for this parent cat if (isset($categories[$parentCatId]) && !empty($categories[$parentCatId])) { $i = 1; foreach ($categories[$parentCatId] as $subCat) { // If we don't have permission to view this category then skip if (!CustomerGroupHasAccessToCategory($subCat['categoryid'])) { continue; } $catLink = CatLink($subCat['categoryid'], $subCat['catname'], false); $catName = isc_html_escape($subCat['catname']); $GLOBALS['SubCategoryList'] = $this->GetSubCategory($categories, $subCat['categoryid']); //set the class for the last category of its parent category $GLOBALS['LastChildClass'] = ''; if ($i == count($categories[$parentCatId])) { $GLOBALS['LastChildClass'] = 'LastChild'; } $i++; $GLOBALS['CategoryName'] = $catName; $GLOBALS['CategoryLink'] = $catLink; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList"); } } if ($output != '') { $output = '<ul>' . $output . '</ul>'; } return $output; }
function GetCategoryListing($catgids, $catgcount, $str_link, $numrows) { $categories = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('RootCategories'); $path = $this->path; $catg_selected = ""; $catg_id_selected = ""; $is_mmy_selected = 0; // this var is used to check whether all mmy is selected or not. 0 for not selected and 1 for selected. if (isset($GLOBALS['ISC_SRCH_CATG_ID']) && isset($GLOBALS['ISC_SRCH_CATG_NAME'])) { // this condition is when any main category is selected from the side bar $catg_id_selected = $GLOBALS['ISC_SRCH_CATG_ID']; $catg_selected = $GLOBALS['ISC_SRCH_CATG_NAME']; } $catg_list = array(); $catg_count_list = array(); $catg_qry = "select categoryid , catparentid from [|PREFIX|]categories"; $catg_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_qry); while ($catg_row = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_res)) { $catg_list[$catg_row['categoryid']] = $catg_row['catparentid']; } //print_r($catgcount); for ($j = 0; $j < count($catgids); $j++) { $id = $catgids[$j]; if (!isset($catg_count_list[$id])) { $catg_count_list[$id] = 0; } if (isset($catg_list[$id]) && $catg_list[$id] == 0) { $catg_count_list[$id] += $catgcount[$id]['count']; } else { if (!isset($catg_count_list[$catg_list[$id]])) { $catg_count_list[$catg_list[$id]] = 0; } $catg_count_list[$catg_list[$id]] += $catgcount[$id]['count']; } } $output = ''; ##################################################################################### $dept = array(); $cat_dept = array(); $cat_department = array(); $cat_dept_qry = "select categoryid , catdeptid , deptname from [|PREFIX|]categories c left join [|PREFIX|]department d on d.deptid = c.catdeptid where catparentid = 0 and catvisible = 1 order by deptname asc, catdeptid desc, catname"; $cat_dept_res = $GLOBALS['ISC_CLASS_DB']->Query($cat_dept_qry); while ($cat_dept_row = $GLOBALS['ISC_CLASS_DB']->Fetch($cat_dept_res)) { //$cat_department[$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['deptname']; $dept[$cat_dept_row['catdeptid']] = $cat_dept_row['deptname']; $cat_dept[$cat_dept_row['categoryid']] = $cat_dept_row['catdeptid']; if (isset($categories[0][$cat_dept_row['categoryid']])) { $categories[0][$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['catdeptid']; } } //arsort($cat_dept); foreach ($cat_dept as $key => $value) { if (isset($categories[0][$key])) { $cat_department[0][$key] = $categories[0][$key]; } } $categories = $cat_department; $mmy_links = ""; //if(isset($GLOBALS['ISC_CLASS_ABTESTING'])) { $params = $this->searchterms; unset($params['subcategory'], $params['category']); $params_catg = $params; //$GLOBALS['ClearURL'] = "$path/search.php?search_query=".urlencode($params['search_query']).$mmy_links; $GLOBALS['ClearURL'] = ""; /* checked whether all MMY are selected */ if (isset($params['make']) && isset($params['year']) && isset($params['model']) && (!isset($params['model_flag']) || isset($params['model_flag']) && $params['model_flag'] == 1)) { $is_mmy_selected = 1; } $GLOBALS['CategoryJSFunction'] = "getvalueswithajax('all_category','{$str_link}&categories={$catg_id_selected}');checkanimate('all_category')"; //} $GLOBALS['ISC_CLASS_VALID_CATEGORIES'] = GetClass('ISC_VALID_CATEGORY'); $GLOBALS['ISC_CLASS_VALID_CATEGORIES']->_ProcessCategories($categories); if (empty($catg_selected)) { // this condition is used to show all categories $iscategorycount = 0; if (isset($params['brand']) || $numrows == 0) { $iscategorycount = 1; } unset($params['brand'], $params['series'], $params_catg['brand'], $params_catg['series']); if (isset($params['brand'])) { unset($params_catg['brand']); } $mmy_links = $this->GetYMMLinks($params_catg); $mmy_links .= $this->GetOtherLinks($params_catg); $GLOBALS['contentid'] = "all_category"; if (isset($GLOBALS['CategoryJSFunction'])) { $GLOBALS['arrowimage'] = "<img src='{$path}/templates/default/images/imgHdrDropDownIcon.gif' border='0' id='all_categoryimage'>"; } $temp_dept = ""; foreach ($categories[0] as $rootCat) { // If we don't have permission to view this category then skip if (!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) { continue; } if (!isset($GLOBALS['ISC_CLASS_VALID_CATEGORIES']->_newcategoryids[$rootCat['categoryid']])) { // not displaying the catg which are having zero products from main catg listing continue; } if ($temp_dept != $rootCat['catdeptid']) { if (!empty($temp_dept)) { $output .= "</ul>"; } if (!empty($dept[$rootCat['catdeptid']])) { $GLOBALS['deptname'] = $dept[$rootCat['catdeptid']]; } else { $GLOBALS['deptname'] = "Other Departments"; } $GLOBALS['deptid'] = "dept" . $rootCat['catdeptid']; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryDepartment"); $output .= "<ul id='" . $GLOBALS['deptid'] . "'>"; //$output .= "<ul><li style='background-color: rgb(255, 15, 25);font-size:12px'>".$dept[$rootCat['catdeptid']]."</li></ul><ul>"; $temp_dept = $rootCat['catdeptid']; } //$GLOBALS['SubCategoryList'] = $this->GetSubCategory($categories, $rootCat['categoryid']); $GLOBALS['LastChildClass'] = ''; $GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']); $RootCatName = $rootCat['catname']; //$GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName).$mmy_links; if (isset($params['brand'])) { $RootCatName = $params['brand']; if ($GLOBALS['EnableSEOUrls'] == 1) { $GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName) . $mmy_links . "/category/" . strtolower(MakeURLSafe($rootCat['catname'])); } else { $GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName) . $mmy_links . "&category=" . strtolower(MakeURLSafe($rootCat['catname'])); } } else { $RootCatName = $rootCat['catname']; $GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName) . $mmy_links; } if (!isset($catg_count_list[$rootCat['categoryid']])) { $catg_count_list[$rootCat['categoryid']] = 0; } $GLOBALS['LastChildClass'] = ""; if ($catg_count_list[$rootCat['categoryid']] > 0) { $GLOBALS['LastChildClass'] = "validcatg"; } //if( isset($params['brand']) || $is_mmy_selected == 1 ) if ($iscategorycount == 0) { $GLOBALS['CategoryCount'] = "(" . $catg_count_list[$rootCat['categoryid']] . ")"; } $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList"); } $output .= "</ul>"; } else { // this condition has been added for showing only selected category $brand_selected = ""; if (isset($params_catg['brand'])) { $brand_selected = MakeURLSafe(strtolower($params_catg['brand'])); unset($params_catg['brand']); } $mmy_links = $this->GetYMMLinks($params_catg); if ($GLOBALS['EnableSEOUrls'] == 1) { $catg_clear_urls = "{$path}"; /*if($brand_selected != "") $catg_clear_urls .= "/".$brand_selected;*/ } else { $catg_clear_urls = "{$path}/search.php?search_query="; if ($brand_selected != "") { $catg_clear_urls .= $brand_selected; } else { $catg_clear_urls .= "categories"; } if ($mmy_links == "") { $catg_clear_urls = "{$path}/"; } } if (!empty($mmy_links)) { $catg_clear_urls .= $mmy_links; } $GLOBALS['ClearURL'] = "<a href='{$catg_clear_urls}'>Clear</a>"; $GLOBALS['arrowimage'] = "<img src='{$path}/templates/default/images/imgHdrDropDownIconright.gif' id='all_categoryimage'>"; //$GLOBALS['Dynimage'] = "/store/templates/default/images/.gif"; //$GLOBALS['SubCategoryList'] = $this->GetSubCategory($categories, $catg_id_selected); $GLOBALS['LastChildClass'] = ''; $GLOBALS['CategoryName'] = "<img src='{$path}/templates/default/images/check.gif'> " . isc_html_escape($catg_selected); //$GLOBALS['CategoryLink'] = "#"; $GLOBALS['CategoryLink'] = $mmy_links; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList1"); $output .= "</ul></div><div id='all_category' class='BlockContent hidelist'>"; $temp_dept = ""; /*foreach($categories[0] as $rootCat) { // If we don't have permission to view this category then skip if(!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) { continue; } if($temp_dept != $rootCat['catdeptid']) { if(!empty($temp_dept)) $output .= "</ul>"; if(!empty($dept[$rootCat['catdeptid']])) $GLOBALS['deptname'] = $dept[$rootCat['catdeptid']]; else $GLOBALS['deptname'] = "Other Departments"; $GLOBALS['deptid'] = "dept".$rootCat['catdeptid']; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryDepartment"); $output .= "<ul id='".$GLOBALS['deptid']."'>"; //$output .= "<ul><li style='background-color: rgb(255, 15, 25);font-size:12px'>".$dept[$rootCat['catdeptid']]."</li></ul><ul>"; $temp_dept = $rootCat['catdeptid']; } if($catg_selected != $rootCat['catname']) { // not displaying the selected category again //$GLOBALS['SubCategoryList'] = $this->GetSubCategory($categories, $rootCat['categoryid']); $GLOBALS['LastChildClass']=''; $GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']); //if(eregi('search.php',$_SERVER['REQUEST_URI'])) //echo $_SERVER['REQUEST_URI']; $GLOBALS['CategoryLink'] = "$path/search.php?search_query=".urlencode($rootCat['catname'])."$mmy_links"; //else //$GLOBALS['CategoryLink'] = CatLink($rootCat['categoryid'], $rootCat['catname'], true); $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList"); } }*/ } $GLOBALS['SearchCategoryList'] = $output; ##################################################################################### $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchCategoryList"); return $output; }
public function ShowPage() { if ($this->_prodid > 0) { $GLOBALS['ProductIds'] = $this->_prodid; // Check that the customer has permisison to view this product $canView = false; $path = GetConfig('ShopPath'); $productCategories = explode(',', $this->_product['prodcatids']); foreach ($productCategories as $categoryId) { // Do we have permission to access this category? if (CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if ($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } if ($this->_prodmetakeywords != "") { $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords(isc_html_escape($this->_prodmetakeywords)); } if ($this->_prodmetadesc != "") { $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(isc_html_escape($this->_prodmetadesc)); } $GLOBALS['CompareLink'] = CompareLink(); // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product if (GetConfig('ProductImageMode') == 'lightbox') { $GLOBALS['AdditionalStylesheets'][] = GetConfig('ShopPath') . '/javascript/jquery/plugins/lightbox/lightbox.css'; } $url_string = $_SERVER['REQUEST_URI']; if (isset($_SERVER['QUERY_STRING'])) { $url_string .= $_SERVER['QUERY_STRING']; } if (eregi('refer=true', $url_string) && isset($_SESSION['back2url'])) { $GLOBALS['B2Search'] = " < <a href='{$path}/" . $_SESSION['back2url'] . "'>Back to search results</a>"; } else { $_SESSION['v_cols'] = array(); $_SESSION['p_cols'] = array(); } //zcs=>only login customer can access "Product Reviews" $GLOBALS['StyleProductReviews'] = CustomerIsSignedIn() ? 'style="text-decoration:none;"' : 'style="display:none;"'; //<=zcs $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($this->_prodlayoutfile); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } else { ShowInvalidError('product'); die; } }
public function PostReview() { $product_id = (int)$_POST['product_id']; $query = "SELECT * FROM [|PREFIX|]products WHERE productid='".(int)$product_id."'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $prodLink = ProdLink($product['prodname']); if(GetConfig('EnableProductTabs') == 0) { $prodReviewsLink = $prodLink.'#reviews'; } else { $prodReviewsLink = Interspire_Url::modifyParams($prodLink, array('tab' => 'ProductReviews')); } if(!$product['prodname']) { // Abandon ship! ob_end_clean(); header("Location:" . $GLOBALS['ShopPath']); die(); } // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach($productCategories as $categoryId) { // Do we have permission to access this category? if(CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } // Are reviews disabled? Just send the customer back to the product page if(!getProductReviewsEnabled()) { header("Location: ".$prodReviewsLink); exit; } // Setup an array containing all of the fields from the POST that we care about for reviews. // We'll use this below, and in the case that we need to redirect back to the product page. $reviewPostData = array(); $reviewFields = array( 'revrating', 'revtitle', 'revtext', 'revfromname', 'product_id' ); foreach($reviewFields as $field) { if(!isset($_POST[$field])) { $reviewPostData[$field] = ''; continue; } $reviewPostData[$field] = $_POST[$field]; } // Check all required fields have been supplied $requiredFields = array( 'revrating', 'revtitle', 'revtext' ); foreach($requiredFields as $field) { if(!isset($_POST[$field]) || !trim($_POST[$field])) { $_SESSION['productReviewData'] = $reviewPostData; FlashMessage(GetLang('InvalidReviewFormInput'), MSG_ERROR, $prodReviewsLink, 'reviews'); exit; } } $captcha = ''; if(isset($_POST['captcha'])) { $captcha = $_POST['captcha']; } $captcha_check = true; // Should reviews be approved automatically? if(GetConfig('AutoApproveReviews')) { $status = 1; } else { $status = 0; } // Do we need to check captcha? if(GetConfig('CaptchaEnabled') && isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) { $_SESSION['productReviewData'] = $reviewPostData; FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews'); exit; } // Save the review in the database $newReview = array( "revproductid" => (int)$reviewPostData['product_id'], "revfromname" => $reviewPostData['revfromname'], "revdate" => time(), "revrating" => max(1, min(5, $reviewPostData['revrating'])), "revtext" => $reviewPostData['revtext'], "revtitle" => $reviewPostData['revtitle'], "revstatus" => $status ); if(!$GLOBALS['ISC_CLASS_DB']->InsertQuery("reviews", $newReview)) { $_SESSION['productReviewData'] = $reviewPostData; FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews'); exit; } // Determine what the success message should be - is the review live // or is it pending approval from the site owner? // If this is an automagically approved review, we need to show that & update the average rating if($status == 1) { $query = " UPDATE [|PREFIX|]products SET prodnumratings=prodnumratings+1, prodratingtotal=prodratingtotal+'".(int)$reviewPostData['revrating']."' WHERE productid='".$product['productid']."' "; $GLOBALS['ISC_CLASS_DB']->Query($query); $flashMessage = GetLang('ReviewSavedApproved'); } else { $flashMessage = GetLang('ReviewSavedPending'); } FlashMessage($flashMessage, MSG_SUCCESS, $prodReviewsLink, 'reviews'); exit; }
private function AddToCart() { if (!isset($_REQUEST['product_id'])) { ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", GetConfig('ShopPath'))); die; } // First get the list of existing products in the cart $product_id = (int) $_REQUEST['product_id']; $GLOBALS['ProductJustAdded'] = $product_id; $query = "\n\t\t\t\tSELECT p.*, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tWHERE p.productid='" . (int) $product_id . "'\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $GLOBALS['Product'] =& $product; // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach ($productCategories as $categoryId) { // Do we have permission to access this category? if (CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if ($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $variation = 0; if (isset($_REQUEST['variation_id']) && $_REQUEST['variation_id'] != 0) { $variation = (int) $_REQUEST['variation_id']; } else { if (isset($_REQUEST['variation']) && is_array($_REQUEST['variation']) && $_REQUEST['variation'][1] != 0) { $variation = $_REQUEST['variation']; } } $qty = 1; if (isset($_REQUEST['qty'])) { if (is_array($_REQUEST['qty'])) { $qty = (int) array_pop($_REQUEST['qty']); } else { if ($_REQUEST['qty'] > 0) { $qty = (int) $_REQUEST['qty']; } } } $configurableFields = null; if (isset($_REQUEST['ProductFields']) || isset($_FILES['ProductFields'])) { $configurableFields = $this->BuildProductConfigurableFieldData(); } $options = array(); if (isset($_REQUEST['EventDate']['Day'])) { $result = true; $eventDate = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']); $eventName = $product['prodeventdatefieldname']; if ($product['prodeventdatelimitedtype'] == 1) { if ($eventDate < $product['prodeventdatelimitedstartdate'] || $eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 2) { if ($eventDate < $product['prodeventdatelimitedstartdate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 3) { if ($eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } } } if ($result == false) { $this->ShowRegularCart(); return; } $options['EventDate'] = $eventDate; $options['EventName'] = $eventName; } // Actually add the product to the cart $cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options); $this->newCartItem = $cartItemId; if ($cartItemId === false) { $this->cartErrorMessage = implode('<br />', $this->api->GetErrors()); if (!$this->cartErrorMessage) { $this->cartErrorMessage = GetLang('ProductUnavailableForPruchase'); } if ($this->api->productLevelError == true) { $query = "\n\t\t\t\t\t\tSELECT prodname\n\t\t\t\t\t\tFROM [|PREFIX|]products\n\t\t\t\t\t\tWHERE productid='" . (int) $product_id . "'\n\t\t\t\t\t"; $productName = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $_SESSION['ProductErrorMessage'] = $this->cartErrorMessage; ob_end_clean(); header("Location: " . ProdLink($productName)); exit; } $this->ShowRegularCart(); return; } $this->api->ReapplyCouponsFromCart(); //Added by Simha temp fix to avoid having multiple times coupon for same item $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->UpdateCartInformation(); $_SESSION['JustAddedProduct'] = $product_id; // Are we redirecting to a specific location? if (isset($_REQUEST['returnUrl'])) { $redirectLocation = urldecode($_REQUEST['returnUrl']); $urlPieces = @parse_url($redirectLocation); $storeUrlPieces = @parse_url(GetConfig('ShopPath')); if (is_array($urlPieces) && isset($urlPieces['host'])) { $urlHost = str_replace('www.', '', isc_strtolower($urlPieces['host'])); $storeHost = str_replace('www.', '', isc_strtolower($storeUrlPieces['host'])); if ($urlHost == $storeHost) { if (strpos($redirectLocation, '?') === false) { $redirectLocation .= '?'; } else { $redirectLocation .= '&'; } $redirectLocation .= 'justAddedProduct=' . $product_id; ob_end_clean(); header("Location: " . $redirectLocation); exit; } } } // Redirect the user to the regular cart page ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", $GLOBALS['ShopPath'])); die; }
public function ShowPage() { if ($this->_prodid > 0) { // Check that the customer has permission to view this product $canView = false; $productCategories = explode(',', $this->_product['prodcatids']); foreach($productCategories as $categoryId) { // Do we have permission to access this category? if(CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } if ($this->_prodmetakeywords != "") { $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords(isc_html_escape($this->_prodmetakeywords)); } if ($this->_prodmetadesc != "") { $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(isc_html_escape($this->_prodmetadesc)); } $GLOBALS['ISC_CLASS_TEMPLATE']->SetCanonicalLink(ProdLink($this->_prodname)); $GLOBALS['CompareLink'] = CompareLink(); // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product if(GetConfig('ProductImageMode') == 'lightbox') { $GLOBALS['AdditionalStylesheets'][] = GetConfig('ShopPath').'/javascript/jquery/plugins/lightbox/lightbox.css'; } $GLOBALS['AdditionalMetaTags'] = ISC_OPENGRAPH::getMetaTags($this->_opengraph_type, $this->_opengraph_title, $this->_opengraph_description, $this->_opengraph_image, ProdLink($this->_prodname)); ISC_PRODUCT_VIEWS::logView($this->_prodid); $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->BuildTitle()); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($this->getLayoutFile()); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } // Visiting an invalid product, show a lovely error message else { $GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404'); $GLOBALS['ISC_CLASS_404']->HandlePage(); exit; } }
public function SetPanelSettings() { $GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY'); // Output breadcrumb trail $GLOBALS['SNIPPETS']['CatTrail'] = ""; if ($GLOBALS['EnableSEOUrls'] == 1) { $baseLink = sprintf("%s/categories", $GLOBALS['ShopPath']); } else { $baseLink = sprintf("%s/categories.php?category=", $GLOBALS['ShopPath']); } $count = 0; $catPath = ''; if (isset($GLOBALS['CatTrail']) && is_array($GLOBALS['CatTrail'])) { foreach($GLOBALS['CatTrail'] as $trail) { $baseLink .= "/" . MakeURLSafe($trail[1]); $catPath .= MakeURLSafe($trail[1])."/"; $GLOBALS['CatTrailName'] = isc_html_escape($trail[1]); $GLOBALS['CatTrailLink'] = $baseLink; if($count++ == count($GLOBALS['CatTrail'])-1) { $GLOBALS['SNIPPETS']['CatTrail'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItemCurrent"); } else { $GLOBALS['SNIPPETS']['CatTrail'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("BreadcrumbItem"); } } } $catPath = rtrim($catPath, "/"); // Output sub-categories $GLOBALS['SNIPPETS']['SubCategories'] = ""; $query = sprintf("select * from [|PREFIX|]categories where catparentid='%d' and catvisible=1 order by catsort asc, catname asc", $GLOBALS['ISC_CLASS_DB']->Quote($GLOBALS['CatId'])); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { // Check to see if we need to add in place holder images or if we are just displaying text if (!($rtn = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['ISC_CLASS_DB']->Query("SELECT COUNT(*) AS Total FROM [|PREFIX|]categories WHERE catparentid='" . (int)$GLOBALS['CatId'] . "' AND catimagefile != ''"))) || !$rtn['Total']) { $useImages = false; } else { $useImages = true; if (GetConfig('CategoryDefaultImage') !== '') { $defaultImage = GetConfig('ShopPath') . '/' . GetConfig('CategoryDefaultImage'); } else { $defaultImage = $GLOBALS['IMG_PATH'].'/CategoryDefault.gif'; } } $i = 0; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $i++; if (!CustomerGroupHasAccessToCategory($row['categoryid'])) { continue; } $GLOBALS['SubCatName'] = isc_html_escape($row['catname']); $GLOBALS['SubCatLink'] = CatLink($row['categoryid'], $row['catname']); if ($useImages) { if ($row['catimagefile'] !== '') { $GLOBALS['SubCatImage'] = GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $row['catimagefile']; } else { $GLOBALS['SubCatImage'] = $defaultImage; } $GLOBALS['ISC_CLASS_TEMPLATE']->assign('width', getConfig('CategoryImageWidth')); $GLOBALS['ISC_CLASS_TEMPLATE']->assign('height', getConfig('CategoryImageHeight') + 50); $GLOBALS['SNIPPETS']['SubCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCatItemImage"); if ($i % GetConfig('CategoryPerRow') == 0) { $GLOBALS['SNIPPETS']['SubCategories'] .= '<li class="RowDivider" style="float:none; clear:both;"></li>'; } } else { $GLOBALS['SNIPPETS']['SubCategories'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCatItem"); } } if ($useImages) { if ($i % GetConfig('CategoryPerRow') > 0) { $GLOBALS['SNIPPETS']['SubCategories'] .= '<li style="float: none; clear: both;"/>'; } $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoriesGrid"); } else { $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategories"); } $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']); $GLOBALS['SNIPPETS']['SubCategories'] = $output; } if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > 1) { // Parse the sort select box snippet $queryStringAppend = array(); if(!empty($_GET['price_min'])) { $queryStringAppend['price_min'] = (float)$_GET['price_min']; } if(!empty($_GET['price_max'])) { $queryStringAppend['price_max'] = (float)$_GET['price_max']; } if($GLOBALS['EnableSEOUrls'] == 1) { $GLOBALS['URL'] = CatLink($GLOBALS['CatId'], $GLOBALS['ISC_CLASS_CATEGORY']->GetName(), false); } else { $GLOBALS['URL'] = $GLOBALS['ShopPath']."/categories.php"; $queryStringAppend['category'] = $catPath; } $GLOBALS['HiddenSortField'] = ''; foreach($queryStringAppend as $k => $v) { $GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"".$k."\" value=\"".isc_html_escape($v)."\" />"; } $GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox"); } // Is the category empty? if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() == 0) { $GLOBALS['ExtraCategoryClass'] = "Wide WideWithLeft"; if($GLOBALS['SNIPPETS']['SubCategories'] != '') { $GLOBALS['CategoryProductListing'] = ''; } $GLOBALS['HideRightColumn'] = "none"; } }
public function PostReview() { $product_id = (int) $_POST['product_id']; $query = "SELECT * FROM [|PREFIX|]products WHERE productid='" . (int) $product_id . "'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if (!$product['prodname']) { // Abandon ship! ob_end_clean(); header("Location:" . $GLOBALS['ShopPath']); die; } // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach ($productCategories as $categoryId) { // Do we have permission to access this category? if (CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if ($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } // Are reviews disabled? Just send the customer back to the product page if (GetConfig('EnableProductReviews') == 0) { $prod_link = ProdLink($product['prodname']); header("Location: " . $prod_link); exit; } // lguan_20100619: Remove checking of rev text since it will be hide from UI // lguan_20100709: Remove the overall rating check, it's no more mandatory if (!isset($_POST['revtitle'])) { $_SESSION['ProductErrorMessage'] = GetLang("InvalidReviewFormInput"); $prod_link = ProdLink($product['prodname']); header("Location: " . $prod_link); exit; } // lguan_20100709: If the rating is not selected, set it to 0 $revrating = isset($_POST['revrating']) ? (double) $_POST['revrating'] : 0; $revtitle = $_POST['revtitle']; $revtext = $_POST['revtext']; $revfromname = $_POST['revfromname']; $captcha = ''; if (isset($_POST['captcha'])) { $captcha = $_POST['captcha']; } $captcha_check = true; //lguan_20100612: Log extra rating info $qualityrating = isset($_POST['qualityrating']) ? (double) $_POST['qualityrating'] : 0; $installrating = isset($_POST['installrating']) ? (double) $_POST['installrating'] : 0; $valuerating = isset($_POST['valuerating']) ? (double) $_POST['valuerating'] : 0; $supportrating = isset($_POST['supportrating']) ? (double) $_POST['supportrating'] : 0; $deliveryrating = isset($_POST['deliveryrating']) ? (double) $_POST['deliveryrating'] : 0; // Should reviews be approved automatically? if (GetConfig('AutoApproveReviews')) { $status = 1; } else { $status = 0; } // Do we need to check captcha? if (GetConfig('CaptchaEnabled')) { if (isc_strtolower($captcha) == isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) { // Captcha validation succeeded $captcha_check = true; } else { // Captcha validation failed $captcha_check = false; } } /* To insert sku, vendorprefix in the review table -- Baskaran */ $vendorprefix = $product['prodvendorprefix']; $prodsku = $product['prodcode']; $source = "TruckChamp.com"; if ($captcha_check) { $orderid = 0; if (isset($_POST['order_id'])) { $orderid = base64_decode($_POST['order_id']); } //echo $orderid ." ".$_POST['order_id']; die(); // Everything is OK, save the darn review already! //lguna_20100612: Log extra infomration for prod review, including more rating info and YMM $NewReview = array("revproductid" => $product_id, "revfromname" => $revfromname, "revdate" => time(), "revtext" => $revtext, "revtitle" => $revtitle, "revstatus" => $status, "revprodsku" => $prodsku, "revprodvendorprefix" => $vendorprefix, "revsource" => $source, "prodyear" => isset($_SESSION['searchterms']['year']) ? $_SESSION['searchterms']['year'] : '', "prodmake" => isset($_SESSION['searchterms']['make']) ? $_SESSION['searchterms']['make'] : '', "prodmodel" => isset($_SESSION['searchterms']['model']) ? $_SESSION['searchterms']['model'] : '', "reviewtype" => isset($_POST['popupFlag']) && $_POST['popupFlag'] == 1 ? 1 : 0, "orderid" => $orderid, 'customerid' => GetClass('ISC_CUSTOMER')->GetCustomerId()); //lguan_20100709: Allow NULL value for those rating options if ($revrating != 0) { $NewReview["revrating"] = $revrating; } if ($qualityrating != 0) { $NewReview["qualityrating"] = $qualityrating; } if ($installrating != 0) { $NewReview["installrating"] = $installrating; } if ($valuerating != 0) { $NewReview["valuerating"] = $valuerating; } if ($supportrating != 0) { $NewReview["supportrating"] = $supportrating; } if ($deliveryrating != 0) { $NewReview["deliveryrating"] = $deliveryrating; } if ($GLOBALS['ISC_CLASS_DB']->InsertQuery("reviews", $NewReview)) { // Determine what the success message should be - is the review live // or is it pending approval from the site owner? $GLOBALS['ReviewSaved'] = true; // If this is an automagically approved review, we need to show that & update the average rating //lguan_20100709: Rating will only be calculated if it is not 0 if ($status == 1 && $revrating != 0) { $query = sprintf("update [|PREFIX|]products set prodnumratings=prodnumratings+1, prodratingtotal=prodratingtotal+%s where productid=%s", $revrating, $product_id); $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['ReviewMessage'] = GetLang('ReviewSavedApproved'); } else { $GLOBALS['ReviewMessage'] = GetLang('ReviewSavedPending'); //2011-2-21 Ronnie add, popup review show another info if (@$_POST['popupFlag'] == 1) { $GLOBALS['ReviewMessage'] = GetLang('ReviewSavedPending2'); } } //wirror20100728: methods for order review request $this->_toLocation($product_id); exit; } else { // Query failed, go back to the product review form $GLOBALS['ReviewError'] = true; //wirror20100728: methods for order review request $this->_toLocation($product_id); } } else { // Captcha check failed, go back to the product review form $GLOBALS['BadCaptcha'] = true; $this->_toLocation($product_id); } }
function searchcategories($params, $selected_value) { $GLOBALS['ISC_CategoryBrandCache'] = GetClass('ISC_CACHECATEGORYBRANDS'); $cachedCategoryBrands = $GLOBALS['ISC_CategoryBrandCache']->getCategoryBrandsData(); $ValidCats = $GLOBALS['ISC_CategoryBrandCache']->GetValidCategories($cachedCategoryBrands); $output = ""; unset($params['brand'], $params['series']); // this is added as brand should not be selected when category is being selected $searchQueries = BuildProductSearchQuery($params); $mmy_links = ""; // this link is used for applying href links of MMY $brand = ""; if (isset($params['brand']) && isset($params['category'])) { $brand = $params['brand']; unset($params['brand']); } unset($params['category'], $params['srch_category']); $mmy_links = $this->GetYMMLinks($params); foreach ($this->items as $qkey => $qval) { if (preg_match("/^(pq|vq)/", $qkey)) { if ($qkey != 'vqsbedsize' && $qkey != 'vqscabsize') { if ($GLOBALS['EnableSEOUrls'] == 1) { $mmy_links .= "/" . strtolower($qkey) . "/" . MakeURLSafe(strtolower($qval)); } else { $mmy_links .= "&" . strtolower($qkey) . "=" . MakeURLSafe(strtolower($qval)); } } } } /* the below condition is applied as brand has to be assigned to get it in the where condition in general.php */ if ($brand != "") { $params['brand'] = $brand; } $categories = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('RootCategories'); /*echo "<a name='list'>LIST</a>"; echo "<p>Please click on any link from the below list.</p>"; echo "<div style='height:280px;overflow-y:auto;border:1px solid black'>";*/ $dept = array(); $cat_dept = array(); $cat_department = array(); /*$cat_dept_qry = "select categoryid , catdeptid , deptname from [|PREFIX|]categories c left join [|PREFIX|]department d on d.deptid = c.catdeptid where catparentid = 0 and catvisible = 1 order by deptname asc, catdeptid desc, catname"; $cat_dept_res = $GLOBALS['ISC_CLASS_DB']->Query($cat_dept_qry);*/ $CatsDepts = $GLOBALS['ISC_CategoryBrandCache']->GetCatDepts($cachedCategoryBrands); //while($cat_dept_row = $GLOBALS['ISC_CLASS_DB']->Fetch($cat_dept_res)) { foreach ($CatsDepts as $cat_dept_row) { //$cat_department[$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['deptname']; $dept[$cat_dept_row['catdeptid']] = $cat_dept_row['deptname']; $cat_dept[$cat_dept_row['categoryid']] = $cat_dept_row['catdeptid']; if (isset($categories[0][$cat_dept_row['categoryid']])) { $categories[0][$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['catdeptid']; } } //arsort($cat_dept); foreach ($cat_dept as $key => $value) { if (isset($categories[0][$key])) { $cat_department[0][$key] = $categories[0][$key]; } } $categories = $cat_department; $catg_list = array(); $catg_count_list = array(); $catg_qry = "select categoryid , catparentid from [|PREFIX|]categories"; $catg_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_qry); while ($catg_row = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_res)) { $catg_list[$catg_row['categoryid']] = $catg_row['catparentid']; } $searchQueries = BuildProductSearchQuery($params); $searchQueries['query'] = str_replace('USE INDEX (categoryid)', 'USE INDEX (PRIMARY)', $searchQueries['query']); $searchQueries['query'] = str_replace($GLOBALS['srch_where'], " group_concat(DISTINCT c.categoryid separator '~') as categoryid ", $searchQueries['query']); $searchQueries['query'] .= " group by p.productid "; $catg_select_res = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); //print_r($catgcount); while ($catg_select_row = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_select_res)) { $ids = explode('~', $catg_select_row['categoryid']); for ($k = 0; $k < count($ids); $k++) { if (!empty($ids[$k])) { if (!isset($catg_count_list[$ids[$k]])) { $catg_count_list[$ids[$k]] = 0; } if ($catg_list[$ids[$k]] == 0) { $catg_count_list[$ids[$k]] += 1; } else { if (!isset($catg_count_list[$catg_list[$ids[$k]]])) { $catg_count_list[$catg_list[$ids[$k]]] = 0; } $catg_count_list[$catg_list[$ids[$k]]] += 1; } } } } //$GLOBALS['ISC_CLASS_VALID_CATEGORIES'] = GetClass('ISC_VALID_CATEGORY'); //$GLOBALS['ISC_CLASS_VALID_CATEGORIES']->_ProcessCategories($categories); $output .= "<ul>"; $temp_dept = ""; foreach ($categories[0] as $rootCat) { if ($rootCat['categoryid'] != $selected_value) { // If we don't have permission to view this category then skip if (!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) { continue; } if (!in_array($rootCat['categoryid'], $ValidCats)) { continue; } /*if(!isset($GLOBALS['ISC_CLASS_VALID_CATEGORIES']->_newcategoryids[$rootCat['categoryid']]))// not displaying the catg which are having zero products from main catg listing continue;*/ if ($temp_dept != $rootCat['catdeptid']) { if (!empty($temp_dept)) { $output .= "</ul>"; } if (!empty($dept[$rootCat['catdeptid']])) { $GLOBALS['deptname'] = $dept[$rootCat['catdeptid']]; } else { $GLOBALS['deptname'] = "Other Departments"; } $GLOBALS['deptid'] = "dept" . $rootCat['catdeptid']; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryDepartment"); $output .= "<ul id='" . $GLOBALS['deptid'] . "'>"; //$output .= "<ul><li style='background-color: rgb(255, 15, 25);font-size:12px'>".$dept[$rootCat['catdeptid']]."</li></ul><ul>"; $temp_dept = $rootCat['catdeptid']; } $GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']); $category_link = ""; if (isset($_REQUEST['abtesting']) && $_REQUEST['abtesting'] != "") { $RootCatName = $rootCat['catname']; } else { if ($brand == "") { $RootCatName = $rootCat['catname']; } else { $RootCatName = $brand; if ($GLOBALS['EnableSEOUrls'] == 1) { $category_link = "/category/" . MakeURLSafe(Strtolower($rootCat['catname'])); } else { $category_link = "&category=" . MakeURLSafe(Strtolower($rootCat['catname'])); } } } if (isset($_REQUEST['abtesting']) && $_REQUEST['abtesting'] != "") { //Modify 2010-10-19 Ronnie //$GLOBALS['CategoryLink'] = $this->path."/a-b-testing/".MakeURLSafe(strtolower($_REQUEST['abtesting']))."/category/".MakeURLSafe(strtolower($RootCatName)).$mmy_links; $GLOBALS['CategoryLink'] = $this->path . "/" . MakeURLSafe(strtolower($RootCatName)) . $mmy_links; } else { $GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName) . $mmy_links . $category_link; } //$GLOBALS['CategoryLink'] = "$this->path/search.php?search_query=".urlencode($GLOBALS['CategoryName']).$mmy_links; if (!isset($catg_count_list[$rootCat['categoryid']])) { $catg_count_list[$rootCat['categoryid']] = 0; } //$GLOBALS['CategoryCount'] = "(".$catg_count_list[$rootCat['categoryid']].")"; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList"); } } $output .= "</ul>"; return $output; }
private function AddToCart() { $error = false; $product = false; $product_id = false; $isFastCart = GetConfig('FastCartAction') == 'popup' && isset($_REQUEST['fastcart']) && GetConfig('ShowCartSuggestions'); if(isset($_REQUEST['product_id']) && (bool)GetConfig('AllowPurchasing')) { $product_id = (int)$_REQUEST['product_id']; $query = " SELECT p.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]products p WHERE p.productid='".$product_id."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if (!$product) { $error = true; } else { $GLOBALS['ProductJustAdded'] = $product_id; $GLOBALS['Product'] = &$product; } } else { $error = true; } if ($error) { flashMessage(getLang('ProductUnavailableForPruchase'), MSG_ERROR); if ($isFastCart) { // dont show fast cart pop up if an error occurs GetClass('ISC_404')->HandlePage(); return; } else { redirect('cart.php'); } } // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach($productCategories as $categoryId) { // Do we have permission to access this category? if(CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $variation = 0; if(isset($_REQUEST['variation_id']) && $_REQUEST['variation_id'] != 0) { $variation = (int)$_REQUEST['variation_id']; } // User added a variation but had javascript disabled else if(isset($_REQUEST['variation']) && is_array($_REQUEST['variation']) && $_REQUEST['variation'][1] != 0) { $variation = $_REQUEST['variation']; } $qty = 1; if(isset($_REQUEST['qty'])) { if(is_array($_REQUEST['qty'])) { $qty = (int)array_pop($_REQUEST['qty']); } else if($_REQUEST['qty'] > 0) { $qty = (int)$_REQUEST['qty']; } } $configurableFields = null; if(isset($_REQUEST['ProductFields']) || isset($_FILES['ProductFields'])) { $configurableFields = $this->BuildProductConfigurableFieldData(); } if (isset($_REQUEST['EventDate']['Day'])) { $result = true; $eventDate = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'],$_REQUEST['EventDate']['Day'],$_REQUEST['EventDate']['Yr']); $eventName = $product['prodeventdatefieldname']; if ($product['prodeventdatelimitedtype'] == 1) { if ($eventDate < $product['prodeventdatelimitedstartdate'] || $eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } else if ($product['prodeventdatelimitedtype'] == 2) { if ($eventDate < $product['prodeventdatelimitedstartdate']) { $result = false; } } else if ($product['prodeventdatelimitedtype'] == 3) { if ($eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } if ($result == false) { if ($isFastCart) { GetClass('ISC_404')->HandlePage(); return; } else { redirect('cart.php'); } } } $showMinQuantityAdjustment = false; if($product['prodminqty'] && $qty < $product['prodminqty']) { $qty = $product['prodminqty']; $showMinQuantityAdjustment = true; } try { $item = new ISC_QUOTE_ITEM; $item ->setQuote($this->getQuote()) ->setProductId($product_id) ->setQuantity($qty) ->setVariation($variation) ->applyConfiguration($configurableFields); if(!empty($_REQUEST['EventDate'])) { $item ->setEventDate( $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']) ->setEventName($eventName); } $this->getQuote()->addItem($item); } catch(ISC_QUOTE_EXCEPTION $e) { if ($isFastCart) { GetClass('ISC_404')->HandlePage(); return; } if($e->getCode() == ISC_QUOTE_EXCEPTION::ERROR_NO_STOCK && $showMinQuantityAdjustment) { flashMessage(getLang('CannotAddMinQuantityToCart', array( 'minqty' => $qty, 'product' => $product['prodname'] )), MSG_ERROR, prodLink($product['prodname'])); } else { flashMessage($e->getMessage(), MSG_ERROR, prodLink($product['prodname'])); } } if($showMinQuantityAdjustment) { flashMessage(getLang('AddToCartMinimumQuantityNotice', array( 'product' => $product['prodname'], 'qty' => $product['prodminqty'])), MSG_INFO); } $_SESSION['JustAddedProduct'] = $product_id; // Are we redirecting to a specific location? if(isset($_REQUEST['returnUrl'])) { $redirectLocation = urldecode($_REQUEST['returnUrl']); $urlPieces = @parse_url($redirectLocation); $storeUrlPieces = @parse_url(GetConfig('ShopPath')); if(is_array($urlPieces) && isset($urlPieces['host'])) { $urlHost = str_replace('www.', '', isc_strtolower($urlPieces['host'])); $storeHost = str_replace('www.', '', isc_strtolower($storeUrlPieces['host'])); if($urlHost == $storeHost) { if(strpos($redirectLocation, '?') === false) { $redirectLocation .= '?'; } else { $redirectLocation .= '&'; } $redirectLocation .= 'justAddedProduct='.$product_id; redirect($redirectLocation); } } } // Show the new contents of the cart $url = 'cart.php'; if (GetConfig('ShowCartSuggestions')) { $url .= '?suggest='.$item->getId(); } if ($isFastCart) { $this->_setupFastCartData($this->getQuote(), $item); echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('FastCartThickBoxContent'); } else { redirect($url); } }
public function Sitemap($MsgDesc = "", $MsgStatus = "") { //$categories = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('RootCategories'); $catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid , catparentid, catname FROM [|PREFIX|]categories c WHERE catparentid = 0 "); $categories = array(); while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catquery)) { $catid = $catrow['categoryid']; $catparentid = $catrow['catparentid']; $catname = $catrow['catname']; $categories[0][$catid] = array('categoryid' => $catid, 'catparentid' => $catparentid, 'catname' => $catname); } if (!isset($categories[0])) { $this->DontDisplay = true; return; } /*----- the below block has been added to display the categories department wise ----- */ $dept = array(); $cat_dept = array(); $cat_department = array(); $cat_dept_qry = "select categoryid , catdeptid , deptname, catparentid from isc_categories c left join isc_department d on d.deptid = c.catdeptid where catparentid = 0 order by deptname asc, catdeptid desc, catname"; $cat_dept_res = $GLOBALS['ISC_CLASS_DB']->Query($cat_dept_qry); while ($cat_dept_row = $GLOBALS['ISC_CLASS_DB']->Fetch($cat_dept_res)) { //$cat_department[$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['deptname']; $dept[$cat_dept_row['catdeptid']] = $cat_dept_row['deptname']; $cat_dept[$cat_dept_row['categoryid']] = $cat_dept_row['catdeptid']; // $cat_dept[$cat_dept_row['catdeptid']][0] .= $cat_dept_row['categoryid']; if (isset($categories[0][$cat_dept_row['categoryid']])) { $categories[0][$cat_dept_row['categoryid']]['catdeptid'] = $cat_dept_row['catdeptid']; } } foreach ($cat_dept as $key => $value) { if (isset($categories[0][$key])) { $cat_department[0][$key] = $categories[0][$key]; } } $categories = $cat_department; $ValidCats = $this->GetValidCategories(); $output = ''; /* the below two variables are added to apply updown animation and image */ $GLOBALS['contentid'] = "all_category"; if (isset($GLOBALS['CategoryJSFunction'])) { $GLOBALS['arrowimage'] = "<img src='{$path}/templates/default/images/imgHdrDropDownIcon.gif' border='0' id='all_categoryimage'>"; } $temp_dept = ""; foreach ($categories[0] as $rootCat) { // If we don't have permission to view this category then skip if (!CustomerGroupHasAccessToCategory($rootCat['categoryid'])) { continue; } if (in_array($rootCat['categoryid'], $ValidCats)) { $GLOBALS['CategoryCount'] = ""; // making it empty as client told not to show the count on homepage. if ($temp_dept != $rootCat['catdeptid']) { if (!empty($temp_dept)) { $output .= "</ul>"; } if (!empty($dept[$rootCat['catdeptid']])) { $GLOBALS['deptname'] = $dept[$rootCat['catdeptid']]; } else { $GLOBALS['deptname'] = "Others"; } $GLOBALS['deptid'] = "li_" . $rootCat['catdeptid']; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SitemapDepartment"); $output .= "<ul id='" . $GLOBALS['deptid'] . "'>"; // $output .= "<ul><li >".$dept[$rootCat['catdeptid']]."</li></ul><ul>"; $temp_dept = $rootCat['catdeptid']; } $GLOBALS['SubCategoryList'] = $this->GetSubCategory($rootCat['categoryid'], $rootCat['catname']); $GLOBALS['LastChildClass'] = ''; $GLOBALS['CategoryName'] = isc_html_escape($rootCat['catname']); ### Common code for creating links SEO friendly and Non-SEO friendly links $RootCatName = $rootCat['catname']; $GLOBALS['CategoryLink'] = $this->LeftCatLink($RootCatName); $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryList"); } } $output .= "</ul>"; $GLOBALS['output'] = $output; //$query = "SELECT * FROM [|PREFIX|]brands ORDER BY brandname"; $query = "SELECT DISTINCT b . * , \n (SELECT COUNT( productid ) \n FROM [|PREFIX|]products p WHERE p.prodbrandid = b.brandid ) AS products \n FROM [|PREFIX|]brands b \n LEFT JOIN isc_products p ON p.prodbrandid = b.brandid\n ORDER BY b.brandname"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $brand = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($row['products'] != '0') { //$url = htmlspecialchars(BrandLink($row['brandname']), ENT_COMPAT, 'UTF-8'); $brandid = "brand_" . $row['brandid']; $brand .= "<ul id='" . $row['brandid'] . "'>"; // $brand .= $row['brandname']; $GLOBALS['Brandname'] = isc_html_escape($row['brandname']); $GLOBALS['Brandid'] = $row['brandid']; $GLOBALS['BrandLink'] = $this->BrandLink($row['brandname']); $GLOBALS['Serieslist'] = $this->GetSeries($row['brandid'], $row['brandname']); $brand .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SitemapBrand"); $brand .= "</ul>"; } } $GLOBALS['Brand'] = $brand; $CustomPages = '<ul><li><img id="staticDivImg" onclick="hideStaticUrls()" width="19" height="16" src="' . GetConfig('ShopPath') . '/admin/images/minus.gif">Static Pages<ul id="staticDiv">'; if (class_exists('DOMDocument')) { $xml = new DOMDocument(); $xml->load(ISC_BASE_PATH . '/sitemaps/static-pages.xml'); $locDom = $xml->getElementsByTagName('loc'); foreach ($locDom as $loc) { $CustomPages .= '<li><a href="' . $loc->nodeValue . '">' . $loc->nodeValue . '</a></li>'; } } else { //ini_set("display_errors","1"); ini_set("memory_limit", "-1"); require_once ISC_BASE_PATH . '/class.opxml.php'; $xml = new OpXML(); $xml->load(ISC_BASE_PATH . '/sitemaps/static-pages.xml'); $locDom = $xml->getElementsByTagName('loc'); foreach ($locDom as $loc) { $CustomPages .= '<li><a href="' . $loc->nodeValue . '">' . $loc . '</a></li>'; } } $GLOBALS['CustomPages'] = $CustomPages . '</ul></li></ul>'; $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("sitemap"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); /* } else { ob_end_clean(); header(sprintf("Location: %s", $GLOBALS['ShopPath'])); die(); } */ }