get_results($qry,ARRAY_A); $product=$product[0]; if($product[goodsid]!=$itemid) err_exit("ERROR: itemid=$itemid "); return $product; } ############## if($_GET[action]=="add" && $_GET[id]) { $itemid=$_GET[itemid]; $product=validate_getid($_GET[id],$itemid); if ($cart->Get_Cart_Count()>0) { $pos = $cart->Enum_Items(true); while ($pos>=0) { if ($cart->Get_Item_ID($pos)==$itemid) { $cart->Set_Item_Quantity($pos,($cart->Get_Item_Quantity($pos)+1)); $addprod="no"; } $pos = $cart->Enum_Items(); } } if ($addprod!="no") $cart->Add_Item($itemid,$product[name],$product[image],$product[tradeprice]); $_SESSION['cart']=$cart; // redirect("cart.php","Adding..."); // exit; } ################## if ($_GET['action']=="remove") { if(isset($_GET['pos'])) $cart->Del_Item($_GET['pos']); $_SESSION['cart']=$cart; // redirect("cart.php","Removing..."); // exit; } ################## if($_POST['action']=="update") { if ($cart->Get_Cart_Count()>0) { $howmany=$_POST['howmany']; if(is_array($howmany)) foreach($howmany as $pos=>$quantity) { $cart->Set_Item_Quantity($pos,$quantity); } } $_SESSION['cart']=$cart; // redirect("cart.php","Updating..."); // exit; } ################## if($_GET['action']=="emptycart") { $cart->Empty_Cart(); $cart->cart_item=array(); $_SESSION['cart']=$cart; // redirect("cart.php","Empty cart..."); // exit; } ################## $items=$cart->Get_Cart_Count()>0?$cart->cart_item:0; $item_keys=array(); if($items) foreach($items as $key=>$item) { if($item) $items_total=number_format(($items_total + ($item[3]*$item[4])), 2, '.', ''); if($item[2]=="0") $items[$key][2]=""; array_push($item_keys,$key); } if($items==0 OR $items_total=="") $items_total=0; $tpl->assign("items",$items); $tpl->assign("item_keys",$item_keys); $tpl->assign("items_total",$items_total); $tpl->assign("cartsessid",session_id()); unset($items,$items_total,$item_keys); //$_SESSION['cart']=$cart; //@setcookie("cart_count",$cart->cart_count); //ad right_col(); ############ //Best Sales $qry="SELECT o.product_id, o.product_name, COUNT(*) as total FROM orderinfo as o INNER JOIN product as p on (p.goodsid=o.product_id) GROUP BY product_id ORDER BY total DESC LIMIT 0,15"; $best_id=$db->get_col($qry,0); $best_name=$db->get_col(null,1); $tpl->assign("best_id",$best_id); $tpl->assign("best_name",$best_name); unset($best_id,$best_name); //Special Price $qry="SELECT id,name,specialcost FROM product WHERE specialcost != '0.00' ORDER BY addtime DESC LIMIT 0,15"; $sp_id=$db->get_col($qry,0); $sp_name=$db->get_col(null,1); $sp_price=$db->get_col(null,2); $tpl->assign("sp_id",$sp_id); $tpl->assign("sp_name",$sp_name); $tpl->assign("sp_price",$sp_price); unset($sp_id,$sp_name,$sp_price); ########### /* $tpl_vars = $tpl->get_template_vars(); print_rr($tpl_vars); */ $output=$tpl->fetch("cart_,ahp2004.htm"); echo str_replace($tpl_imgdir_name, $tpl->template_dir.$tpl_imgdir_name,$output); ?>