setupClass("Catalogs"); switch($_SESSION['lang']){ case 'ru' : include('../langs/ru.php');$setup->tpl->assign('lang_prefix',''); break; case 'ukr' : include('../langs/ukr.php');$setup->tpl->assign('lang_prefix','ukr/'); break; default : include('../langs/ru.php'); $setup->tpl->assign('lang_prefix','');break; } if(!isset($_SESSION['curs']))$_SESSION['curs'] = "uah"; if(isset($_GET['clear'])){ unset($_SESSION['basket']); unset($_SESSION['shopcart']); unset($_SESSION['cart']); //print_r($_SESSION); } // $discount if(isset($_SESSION['catalog_user']) && $userID=$objCatalogs->isUser($_SESSION['catalog_user']['login'],$_SESSION['catalog_user']['psw'])){ $discount = $objCatalogs->getUserDiscount($userID); } else { $discount = 0; } if(isset($_GET['product_id']) && $_GET['product_id']>0){ $_SESSION['basket'][] = $_GET['product_id']; // ========== ZLODEYEV ============ // ======================================== // ============= êîðçèíà ================== // ======================================== // ==== îáíîâëÿåì ==== // Âûáèðàåì èíôî î òîâàðå $sql4 = "SELECT p.*, m.*,m.sale as msale, m.id as mod_id,IF(m.cine>0,m.cine,p.cine) as cine FROM catalogs_modifications as m LEFT JOIN catalogs_products as p ON p.id=m.product_id WHERE m.id='".$_GET['product_id']."' "; $result4 = mysql_query($sql4) or die(mysql_error()); if (mysql_affected_rows()!=0) { $item=mysql_fetch_assoc($result4); $item['cine'] = round($item['cine'] - ($item['cine']*$item['msale']/100)); } $f=0; if (isset($_SESSION['shopcart'])) { foreach ($_SESSION['shopcart'] as $i => $cart) { if ($cart['code']==$_GET['product_id']) { //echo$cart['code']."=".$_GET['product_id']."
"; $f=1; $_SESSION['shopcart'][$i]['count']=($_SESSION['shopcart'][$i]['count']+1); $_SESSION['shopcart'][$i]['total']=$_SESSION['shopcart'][$i]['count']*$_SESSION['shopcart'][$i]['price']; if ($_SESSION['shopcart'][$i]['total']==0) { unset($_SESSION['shopcart'][$i]); } break; } } } // ==== äîáàâëÿåì ==== // Åñëè íåò â ìàññèâå òî äîáàâëÿåì if ($f==0) { // äîáàâëÿåì â êîðçèíó $_SESSION['shopcart'][] = array( "code"=>$item['mod_id'], "code_txt"=>$item['code'], "price"=>$item['cine'], "count"=>1, "total"=>$item['cine'], ); } // ========== ZLODEYEV ============ } if(isset($_SESSION['basket']) && count($_SESSION['basket'])){ $cine_products = 0; $i=-1; foreach($_SESSION['basket'] as $product_id){ $i++; $cine_products = $cine_products + $objCatalogs->getProductCine($product_id); $_SESSION['cart'][$i]['price']=$objCatalogs->getProductCine($product_id); } $cine_products_discount = $cine_products - (($cine_products*$discount)/100); $_SESSION['cart']['total']= $cine_products_discount; $count_products = count($_SESSION['basket']); } else {$count_products = 0;$cine_products = 0;} $setup->error(); $objCatalogs->viewVarCurs($_SESSION['curs']); if(isset($_SESSION['basket']))$objCatalogs->viewBasketProducts($_SESSION['basket'],$curs,$objCatalogs->getUserDiscount($userID)); $objCatalogs->displayBasket($count_products,$cine_products,$cine_products_discount,$discount); ?>