Ik ben bezig met een site die een winkelwagen systeem heeft.
De bedoeling is dat de code twee dezelfde producten uit de database, waarvan de aantal producten verschillend kan zijn, bij elkaar optelt en niet onder elkaar zet.
Zie hieronder de code:
<%
'controleer of de winkelwagen leeg is
If IsArray(Session("cart")) = false Then
Dim acart(19,1)
Session("cart") = acart
else
acart=session("cart")
end if
cempty=true
for i=lbound(acart) to ubound(acart)
if acart(i,0)<>"" and acart(i,1)<>"" then
cempty=false
end if
next
%>
--------------------------
<%
'Laat de inhoud van de winkelwagen zien
acart=session("cart")
subtotal=0
for i=lbound(acart) to ubound(acart)
if acart(i,0)<>"" and acart(i,1)<>"" then
set rscart=db.execute("select name,productid,price,saleprice from products where productid=" & acart(i,0))
if rscart("saleprice")="" or rscart("saleprice")=0 then
currentprice=rscart("price")
else
currentprice=rscart("saleprice")
end if
%>
-------------------------------
<td align="left"><font color="#006888" face="Verdana">
'het product wordt uit de database gehaald
<a href="product.asp?productid=<%=rscart("productid") %>"><font size=2>
<%= rscart("name") %></font></a><font size=2>
<br>
</font></font>
</td>
'acart(i,1) is het aantal
<td align="center"><font face=Verdana size=2 color="#006888"><%= acart(i,1) %></font></td>
<td align="right"><font face=Verdana size=2 color="#006888"><%= cursymbol & formatnumber(currentprice)%></font></td>
<td align="right"><font face=Verdana size=2 color="#006888"><%= cursymbol & formatnumber(currentprice * acart(i,1)) %></font></td>
</tr>
'Totaal bedrag
<font face="helvetica" size="3" color="<%= COLdark %>">
<%
subtotal=subtotal+(currentprice * acart(i,1))
end if
next
tax=subtotal*taxrate/100
%>
De bedoeling is dat de code twee dezelfde producten uit de database, waarvan de aantal producten verschillend kan zijn, bij elkaar optelt en niet onder elkaar zet.
Zie hieronder de code:
<%
'controleer of de winkelwagen leeg is
If IsArray(Session("cart")) = false Then
Dim acart(19,1)
Session("cart") = acart
else
acart=session("cart")
end if
cempty=true
for i=lbound(acart) to ubound(acart)
if acart(i,0)<>"" and acart(i,1)<>"" then
cempty=false
end if
next
%>
--------------------------
<%
'Laat de inhoud van de winkelwagen zien
acart=session("cart")
subtotal=0
for i=lbound(acart) to ubound(acart)
if acart(i,0)<>"" and acart(i,1)<>"" then
set rscart=db.execute("select name,productid,price,saleprice from products where productid=" & acart(i,0))
if rscart("saleprice")="" or rscart("saleprice")=0 then
currentprice=rscart("price")
else
currentprice=rscart("saleprice")
end if
%>
-------------------------------
<td align="left"><font color="#006888" face="Verdana">
'het product wordt uit de database gehaald
<a href="product.asp?productid=<%=rscart("productid") %>"><font size=2>
<%= rscart("name") %></font></a><font size=2>
<br>
</font></font>
</td>
'acart(i,1) is het aantal
<td align="center"><font face=Verdana size=2 color="#006888"><%= acart(i,1) %></font></td>
<td align="right"><font face=Verdana size=2 color="#006888"><%= cursymbol & formatnumber(currentprice)%></font></td>
<td align="right"><font face=Verdana size=2 color="#006888"><%= cursymbol & formatnumber(currentprice * acart(i,1)) %></font></td>
</tr>
'Totaal bedrag
<font face="helvetica" size="3" color="<%= COLdark %>">
<%
subtotal=subtotal+(currentprice * acart(i,1))
end if
next
tax=subtotal*taxrate/100
%>