Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > PHP > PHP Forum > ดูโค้ดตะกร้าสินค้าให้ผมหน่อยคับ ผมไม่สามารถเปลี่ยนจำนวนสั่งซื้อได้เขียนโค้ดอัพเดทไม่เป็นคับและก็สร้างไฟล์ชำระเงินด้วยอะคับ



 

ดูโค้ดตะกร้าสินค้าให้ผมหน่อยคับ ผมไม่สามารถเปลี่ยนจำนวนสั่งซื้อได้เขียนโค้ดอัพเดทไม่เป็นคับและก็สร้างไฟล์ชำระเงินด้วยอะคับ

 



Topic : 018746

Guest




ผมไม่สามารถเปลี่ยนจำนวนสั่งซื้อได้เขียนโค้ดอัพเดทไม่เป็นคับและก็สร้างไฟล์ชำระเงินด้วยอะคับ ช่วยหน่อยนะคับ งง มากๆ โค้ดยาวไปหน่อยนะคับ
<?php
error_reporting(E_ALL);
session_start();
include("connectionDB.php");
$expire = 3600;
$time=time();
$expire=$time+$expire;
$script_url=$_SERVER["PHP_SELF"];

if(!isset($_SESSION['cart']))
{
if(isset($_COOKIE['cart']))
{
$_SESSION['cart']=array();
$_SESSION['cart']=unserialize(stripslashes($_COOKIE['cart']));
$_SESSION['total_items']=cart_calculate_items($_SESSION['cart']);
$_SESSION['total_price']=cart_calculate_price($_SESSION['cart']);
}
else
{
$_SESSION['cart']=array();
$_SESSION['total_items']=0;
$_SESSION['total_price']=0.00;
$s_cart = serialize($_SESSION['cart']);
setcookie('cart',$s_cart,$expire);
}
}

if($_GET['action']=='add')
{
$item=$_GET['pid'];
if(isset($_SESSION['cart'][$item]))
{
$_SESSION['cart'][$item]++;
}
else
{
$_SESSION['cart'][$item]=1;
}
$_SESSION['total_items']=cart_calculate_items($_SESSION['cart']);
$_SESSION['total_price']=cart_calculate_price($_SESSION['cart']);
$s_cart = serialize($_SESSION['cart']);
header("Location:$script_url?action=view");
exit;
}

if($_GET['action']=="del")
{
$productID=$_GET['pid'];
unset($_SESSION['cart'][$productID]);
$_SESSION['total_items']=cart_calculate_items($_SESSION['cart']);
$_SESSION['total_price']=cart_calculate_price($_SESSION['cart']);
$s_cart = serialize($_SESSION['cart']);
header("Location:$script_url?action=view");
exit;
}


if($_GET['action']=="view")
{
cart_show($_SESSION['cart'],$pictures='false',$editable='true');

}

//=====================
// ฟังก์ชันคำนวณจำนวนสินค้า
function cart_calculate_items($cart)
{
$items=0;
if(is_array($cart))
{
foreach($_SESSION['cart']as $productID =>$qty)
{
$items+=$qty;
}
}
return $items;
}

//======================
// ฟังก์ชันคำนวณราคา
function cart_calculate_price($cart)
{
$price=0.00;
if(is_array($cart))
{
foreach($cart as $productID => $qty)
{
$query ="select price from product where pro_id ='$productID'";
$result = mysql_query($query);
if($result)
{
$row_result=mysql_fetch_assoc($result);
$item_price=$row_result['price'];
$price+=$item_price*$qty;
}
}
}
return $price;
}
//====================================

function db_to_array($result)
{
$result_array=array();
for($count=1;$row=@mysql_fetch_array($result);$count++)
$result_array[$count]=$row;
return $result_array;
}


//====================================
function cart_get_item_details($productID)
{
$query="select * from product where pro_id='$productID'";
mysql_query("SET character_set_results =tis620");
mysql_query("SET character_set_client =tis620");
mysql_query("SET character_set_connection =tis620");
$result = mysql_query($query);
$row_result = mysql_fetch_assoc($result);
return $row_result;
}

//===================================

function cart_show($cart,$pictures='false',$editable='true')
{
include("cart_top.php");
$i=1;
foreach($cart as $productID=>$qty)
{
$product = cart_get_item_details($productID);
$bgcolor=($i++%2)?'#F@FAEB':'#E6F2DF';
echo"<form>\n";
echo"<tr bgcolor=\"$bgcolor\">\n";
echo"<td align=\"center\">";
echo"<a href=\"basket.php?action=del&pid=".$product['pro_id']."\">";
echo"ลบ";
echo"</a>";
echo"</td>\n";
echo"<td>".$product['proname']."</td>\n";
echo"<td valign=top align=center>";
echo"<input type=\"text\" name=\"pro_id\" value=$qty size=2>";
echo"</td>\n";
echo"<td valign=top align=right>".number_format($product['price'],
2,'.',',')."</td>\n";
echo"<td valign=top align=right>".number_format(($qty*$product['price']),2,'.',',')."</td>\n";
echo"</tr>\n";
echo"</form>\n";

}

echo"<tr>\n";
echo"<td colspan=5><hr size=1></td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td colspan=3 align=\"center\"valign=middle>
</td>\n";
echo"<td align=left><b>ยอดรวม</b></td>\n";
echo"<td align=right>".number_format($_SESSION['total_price'],2,'.',',')."</td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td colspan=3rowspan=4>&nbsp;</td>\n";
echo"<td align=left><b>ค่าจัดส่ง</b></td>\n";
echo"<td align=right>";

if($_SESSION['total_price']==0)
{
$pay_delivery=0;
}
else
{
if($_SESSION['total_price']>=1500)
$pay_delivery=0;
else
$pay_delivery=150;
}

echo number_format($pay_delivery,2,'.',',');
echo"</td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td align=left><b>ภาษี 7%</b></td>\n";
echo"<td align=right bgcolor=\"#FFFF99\">";
$tax=$_SESSION['total_price']*0.07;
echo number_format($tax,2,'.',',');
echo"</td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td colspan=3><hr size=1></td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td align=left><b>รวมทั้งสิ้น</b></td>\n";
echo"<td align=right bgcolor=\"#99FF99\">";
$paymoney =($_SESSION['total_price']+$pay_delivery+$tax);
echo number_format($paymoney,2,'.',',');
echo"</td>\n";
echo"</tr>\n";
echo"<tr>\n";
echo"<td colspan=5><br>\n";
echo"หากท่านไม่ได้รับสินค้าภายใน 3 วัน โปรดติดต่อกลับ 085-127-5611</td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"<div align=center>\n";
echo"<p align=center>\n";
echo"<a href=\"product.php\">ซื้อสินค้าต่อ</a>\n";
echo"<a href=\"payment.php\">ชำระเงิน</a>\n";
echo"</div>\n";
include("cart_bottom.php");
}
include("closeDB.php");
?>



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 5 มี.ค. 2551 16:07:04 By : sakdalll View : 1760 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ดูโค้ดตะกร้าสินค้าให้ผมหน่อยคับ ผมไม่สามารถเปลี่ยนจำนวนสั่งซื้อได้เขียนโค้ดอัพเดทไม่เป็นคับและก็สร้างไฟล์ชำระเงินด้วยอะคับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่