 |
|
|
 |
 |
|
<%
If Session("customer_id") = "" Then Response.Redirect "login.asp"
%>
<%
CONST CARTPID=0
CONST CARTPNAME=1
CONST CARTPPRICE=2
CONST CARTPQUANTITY=3
Dim foundIt, i, product_id, product_name, product_price, newQ, deleteProduct
If Not IsArray(Session("cart")) Then
Dim localCart(4,20)
Else
localCart = Session("cart")
End If
product_id = Trim(Request.Form("product_id"))
product_name = Trim(Request.Form("product_name"))
product_price = Trim(Request.Form("product_price"))
If product_id <> "" Then
foundIt = False
For i = 0 To Ubound(localCart,2)
If localCart(CARTPID, i) = product_id Then
localCart(CARTPQUANTITY, i) = localCart(CARTPQUANTITY, i) + 1
foundIt = True
Exit For
End If
Next
If Not foundIt Then
For i = 0 To Ubound(localCart, 2)
If localCart(CARTPID,i) = "" Then
localCart(CARTPID,i) = product_id
localCart(CARTPNAME,i) = product_name
localCart(CARTPPRICE,i) = product_price
localCart(CARTPQUANTITY,i) = 1
Exit For
End If
Next
End If
End If
If Request.Form("updateQ") <> "" Then
For i = 0 To Ubound(localCart,2)
newQ = Trim(Request.Form("pq" & localCart(CARTPID,i)))
deleteProduct = Trim(Request.Form("pd" & localCart(CARTPID,i)))
If newQ = "" Or newQ = "0" Or deleteProduct <> "" Then
localCart(CARTPID,i) = ""
Else
If IsNumeric(newQ) Then
localCart(CARTPQUANTITY,i) = newQ
End If
End If
Next
End If
Session("cart") = localCart
Response.Redirect "viewcart.asp"
%>
ลองดูล่ะกัน
|
 |
 |
 |
 |
Date :
15 ธ.ค. 2550 19:46:14 |
By :
- |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โห เก่งจริง
|
 |
 |
 |
 |
Date :
20 ธ.ค. 2550 14:23:42 |
By :
p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Thanks 
|
 |
 |
 |
 |
Date :
2011-04-14 03:55:21 |
By :
EXPERT-PRO |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|