Merhabalar..
Hotscripts'den aldığım bir sepet sistemi üzerinde bir kaç modifikasyon zoque'daki bazı arkadaşlarında yardımıyla birkaç modifikasyon yaptım...
Örneğin ; Sepet sistemi tek fiyatlı idi ben buna birkaç farklı fiyat olacak şekilde düzenledim ,yani her üyenin bir grubu var ve bu gruba göre kendisine özel fiyatlarını görüyorlar.
Herneyse buraya kadar herşey düzgün bir şekilde çalışıyor. Fakat ben ürünleri sepete eklettiğimde ,bu ürünlerin fiyatlarını ekletemiyorum , çünkü
script tek fiyat üzerine düzenlenmiş ,baya bir kastım ama içinde çıkamadım , gerekli olan kodları veriyorum aşağıda.
Zamanı olun olurda inceleyen olursa yardımlarınızı bekliyorum..
Ürünlerin Listelendiği Source..
------------------------------------------------------------
$query = "SELECT * FROM ".$prefix."store_inventory where cat_id='$cat_id' LIMIT $limitvalue, $limit ";
$result = mysql_query($query) or die("HATA: " . mysql_error());
$count_result = mysql_num_rows($result);
echo"<br><table align=\"center\" valign=\"top\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr bgcolor=\"$colour_2\"><td>
<table cellpadding=\"2\" border=\"0\" cellspacing=\"1\" valign=\"top\" width=\"100%\" align=\"left\">
<tr bgcolor=\"$colour_1\" height=\"20\" width=\"100%\">
<td background=\"images/bevel_bg.gif\" align=\"left\"><b>Ürün Kodu</b></td>
<td background=\"images/bevel_bg.gif\" width=\"20\"align=\"left\"><b>Ürün Adý</b></td>
<td background=\"images/bevel_bg.gif\" align=\"left\"><b>Fiyat</b></td>
<td background=\"images/bevel_bg.gif\" width=\"3\" align=\"right\"><b>Adet</b></td>"
;}
$SQL ="SELECT * FROM store_customer WHERE email = '$valid_user'";
$sorgula = mysql_query ($SQL);
$User = mysql_fetch_array($sorgula);
while($row = mysql_fetch_array($result)){
$product=$row["urunadi"];
$AnaFiyat = $row[$User[grup]];
FiyatDegistir($AnaFiyat );
}
echo" <tr onMouseover=\"changeto(event, 'lightyellow')\" onMouseout=\"changeback(event, '$bgcolour')\" bgcolor=\"$bgcolour\" valign=\"top\" height=\"20\">
<td bgcolor=\"$bgcolour\" align=\"left\"><a href=\"urun_detay.PHP?product=$product\">$
title</a></td>
<td align=\"left\">";
echo"$Fiyat[AnaFiyat]";}
echo"</td>
Birde yukarıdaki dosya içine include ettiğim
Oturum.
PHP
------------------------
[
PHP]
?
PHP
//Oturum
PHP
// Aziz DURMAZ tarafýnda 11.11.2002 de yazýlmýþtýr
session_start();
function FiyatDegistir($UserFiyat) {
global $Fiyat;
$Fiyat[AnaFiyat] = $UserFiyat;
}
?>
Ve Class Dosyam..
------------------------------------
<?PHP
if(!$session && !$ShoppingCart) //make sure this hasn't already been established
{
$session = md5(uniqid(rand())); //creates a random session value
$today_date=date("Ymd");
$expired_date = $today_date - 2;
mysql_query("DELETE FROM ".$prefix."store_shopping WHERE date>='$expired_date'");
//set the cookie to remain for 2 days
SetCookie("ShoppingCart", "$session",time()+86400);
}
// start Cart class
class Cart
{
// add item to shopping database
function add_item($prefix,$session,$product,$quantity)
{
// see if item is already in shopping list
$in_list = "SELECT * FROM ".$prefix."store_shopping WHERE session='$session' AND product='$product'";
$result = mysql_query( "$in_list");
$num_rows = mysql_num_rows($result);
// if not add it
if($num_rows == 0)
{
$date= date("Ymd");
$SQL = "INSERT INTO ".$prefix."store_shopping (session,product,quantity,date) VALUES ('$session','$product','$quantity','$date')";
mysql_query( "$SQL");
}
// if they already have it modify quantity
else
{
$row = mysql_fetch_array($result);
$quantity = $quantity + $row[quantity];
$SQL = "UPDATE ".$prefix."store_shopping SET quantity='$quantity' WHERE session='$session' AND product='$product'";
mysql_query( "$SQL");
}
}
// delete a specific item
function delete_item($prefix,$session,$product)
{
mysql_query( "DELETE FROM ".$prefix."store_shopping WHERE session='$session' AND product='$product'");
}
// modifies a quantity of an item
function modify_quantity($prefix,$session, $product, $quantity)
{
$SQL = "UPDATE ".$prefix."store_shopping SET quantity='$quantity' WHERE session='$session' AND product='$product'";
mysql_query( "$SQL");
}
// clear all content in their cart
function clear_cart($prefix,$session)
{
mysql_query( "DELETE FROM ".$prefix."store_shopping WHERE session='$session'");
}
//add up the shopping cart total
function cart_total($prefix,$session,$sale)
{
$result = mysql_query( "SELECT * FROM ".$prefix."store_shopping WHERE session='$session'");
if(mysql_num_rows($result) >0)
{
while($row = mysql_fetch_array($result))
{
**************************** **************************** **************************** ****************************
// look up the item in inventory
$price_from_inventory = "SELECT sale_price, price FROM ".$prefix."store_inventory WHERE product = '$row[product]'";
$result_inventory = mysql_query("$price_from_inventory");
$row_price = mysql_fetch_array($result_inventory);
//calculate the total depending whether product has sale price or not and sale is on or off
if(($sale=="Y")and($row_price[sale_price]=="0.00"))
{$result_price="price";}
if(($sale=="Y")and($row_price[sale_price]!=="0.00"))
{$result_price="sale_price";}
if($sale=="N")
{$result_price="price";}
// add total
$total = $total + ($row_price[$result_price]*$row[quantity]);
}
}
// format total
return sprintf("%.2f", $total);
}
// function to display contents
function display_contents($prefix,$session,$sale)
{
$count = 0;
$result = mysql_query("SELECT * FROM ".$prefix."store_shopping WHERE session='$session'");
while($row = mysql_fetch_array($result))
{
$result_inv = mysql_query("SELECT * FROM ".$prefix."store_inventory WHERE product='$row[product]'");
$row_inventory = mysql_fetch_array($result_inv);
// select suitable price for product depending on whether it has a sale price and sale is on or off
if(($sale=="Y")and($row_inventory[sale_price]=="0.00"))
{$result_price="price";}
if(($sale=="Y")and($row_inventory[sale_price]!=="0.00"))
{$result_price="sale_price";}
if($sale=="N")
{$result_price="price";}
$contents[ "product"][$count] = $row_inventory[product];
$contents[ "image"][$count] = $row_inventory[image];
$contents[ "title"][$count] = $row_inventory[title];
$contents[ "description"][$count] = $row_inventory[description];
$contents[ "price"][$count] = $row_inventory[$result_price];
$contents[ "quantity"][$count] = $row[quantity];
$contents[ "total"][$count] = ($row_inventory[$result_price] * $row[quantity]);
$count ++;
}
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
$total = $this->cart_total($prefix,$session,$sale);
$contents[ "final"] = $total;
return $contents;
}
// count no items
function num_items($prefix,$session)
{
$result = mysql_query( "SELECT * FROM ".$prefix."store_shopping WHERE session='$session'");
$num_rows = mysql_num_rows($result);
return $num_rows;
}
}
?>
Sanırım değişiklik yapmam gereken kısım class dosyam ve değişiklik yapmam gereken yerlerin işaretli kısımlar olduğunu biliyorum ve bu kısımlar üzerinde baya çalışma yaptım fakat işin içinden çıkamadım..
Yarım etmeye vakti olan arkadaşlardan yardımlarını bekliyorum..
Teşekkürler..