NOW()),0) as discount from drug t1, brand t3 where t1.id='".$id."' and t3.id=t1.brand and t1.sv_type = 1 and t3.sv_type = 1"); if (mysql_num_rows($q)==1) { $r = mysql_fetch_array($q); $cart[$id]['quant'] = 1; $cart[$id]['price'] = $r["price"]-$r["discount"]; $_SESSION['information'] = 'Success: You have added '.$r['name_en'].' to your shopping cart!'; } } if ($del = $_GET['del'] + 0) { foreach ($cart as $k=>$v) if ($k == $del) unset($cart[$k]); $r = mysql_fetch_array(mysql_query(" select t2.name_en from drug t1, brand t2 where t1.id='".$del."' and t2.id=t1.brand and t1.sv_type = 1 and t2.sv_type = 1")); $_SESSION['information'] = 'Success: You have removed '.$r['name_en'].' from your shopping cart!'; } $ids = "0"; foreach ($cart as $k=>$v) $ids .= ",".$k; $q1 = mysql_query(" SELECT t1.id as brand_id, t1.img as brand_img, t1.name_en as brand_name, t2.id, t4.name_en as producer, (ROUND((t1.price*t2.quant*(1-".PERCENT."*(t2.quant/(SELECT MIN(quant) FROM drug t4 WHERE t4.brand = t2.brand AND sv_type = 1)-1)/100)))) as price, t2.quant, t2.dose, COALESCE((SELECT discount FROM discounts WHERE drug = t2.id AND date_off > NOW()),0) as discount, t3.name_en as categ_name FROM brand t1 INNER JOIN drug t2 ON t2.brand=t1.id INNER JOIN categ t3 ON t1.categ=t3.id INNER JOIN producers t4 ON t1.producer = t4.id WHERE t2.id IN (".$ids.") AND t2.sv_type IN (1) ORDER BY t1.ord, t2.ord "); if (mysql_num_rows($q1)>0) while ($r1 = mysql_fetch_array($q1)) { $r1["ppill"] = number_format(($r1['price']-$r1[discount])/$r1['quant'],2); $r1["price"] = number_format($r1[price]-$r1[discount],2); $r1["uri"] = to_uri("order/buy-".$r1[categ_name]."/".$r1[brand_name]."_".$r1['producer'].".html"); if (!$r1["brand_img"]) $r1["brand_img"] = "coming_soon.jpg"; $prod[] = $r1; $carts[subtotal] += $r1[price]; } $carts[subtotal] = number_format($carts[subtotal],2); $smarty->assign("prod", $prod); $smarty->assign("cart", $carts); $_SESSION[cart] = $cart; if ($_REQUEST['del'] || $_REQUEST['drug']) { if ($_SESSION['information']!="") { $smarty->assign("information",$_SESSION['information']); unset($_SESSION['information']); } $smarty->assign("cartbox",view_cart()); } $smarty->assign("Title", "Shopping Cart".TITLE_SUFFIX); $smarty->display('top.html'); $Bread = array ("buy" => "Shopping Cart"); $smarty->assign("Bread", $Bread); $smarty->display('breadcrumb.html'); $smarty->display('cart.html'); include_once('bot.php'); ?>