当前位置: 代码迷 >> 综合 >> asp shopping cart
  详细解决方案

asp shopping cart

热度:11   发布时间:2023-12-13 15:52:41.0
 
<%  
dim proId,qtn,act
act=Request("act")     '根据act的值,来判断采取什么过程.
proId=Request("proId") 'productID
qtn=Request("qtn")     'Quantity
if act="mod" then      '修改商品数量
call uCart.ModifItem(proId,qtn,2)
elseif act="del" then  '删除某个商品
call uCart.DelItem(proId)
elseif act="clearAll" then '清空购物车
call uCart.RemoveAll()
end if
If uCart.CheckItem(proId)=False and act="add" Then '添加产品进行判定,防止刷新页面增加商品
set rs = Server.CreateObject("adodb.recordset")
rs.open "select goods_name,market_price,shop_price,goods_img from t_goods where goods_id="&proId,conn,1,1
if not rs.eof then
call uCart.AddItem(proId,rs("goods_name"),rs("market_price"),rs("shop_price"),0,qtn,rs("goods_img"))
end if
rs.close
set rs=nothing
end if
myCart=uCart.ViewCart() '查看购物车里详细信息
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#DEF3C8">
<tr>
<td width="11%" height="30" align="center" class="font_14hei">图片</td>
<td width="19%" align="center" class="font_14hei">商品名称</td>
<td width="20%" align="center" class="font_14hei">销售价格</td>
<td width="20%" align="center" class="font_14hei">优惠价格</td>
<td width="10%" align="center" class="font_14hei">数量</td>
<td width="10%" align="center" class="font_14hei">金额</td>
<td width="10%" align="center" class="font_14hei">操作</td>
</tr>
<%
For i=LBound(myCart,2) To UBound(myCart,2)
If myCart(0,i)<>"" Then '以前的判断语句
%>
<form name="form1" method="post" action="?act=mod">
<tr>
<td height="30" align="center" bgcolor="#FFFFFF"><img src="<%= myCart(6,i) %>" width="98" height="103" /></td>
<td align="center" bgcolor="#FFFFFF" class="font_12lvse"><%= myCart(1,i) %></td>
<td align="center" bgcolor="#FFFFFF">¥<%= myCart(2,i) %></td>
<td align="center" bgcolor="#FFFFFF">¥<%= myCart(3,i) %></td>
<td align="center" bgcolor="#FFFFFF"><input name="qtn" type="text" value="<%= myCart(5,i) %>" size="2" οnkeyup="this.value=this.value.replace(/\D/g,'')" />
<input type="hidden" name="proId" value="<%= myCart(0,i) %>" />
<input type="submit" value="修改" /></td>
<td align="center" bgcolor="#FFFFFF">¥<% Response.Write(myCart(5,i)*myCart(3,i)) %></td>
<td align="center" bgcolor="#FFFFFF"><a href="?act=del&proId=<%= proId %>">删除</a></td>
</tr>
</form>
<%
End If
Next
if uCart.CheckEmtpy then Response.Write("<td colspan='7' align='center'>暂无购买商品,请继续 <a href='product.asp' style='color:red'>购物</a></td>")
myprice=uCart.TPrice() '得到商品总金额
%>
</table>            
<p style="margin-top:5px;">
<input type="button" value="继续购物" οnclick="window.location.href='product.asp';" />
<input type="button" value="清空购物车" οnclick="window.location.href='?act=clearAll';" />
<span style="margin-left:500px;">商品总额:¥<%
if uCart.CheckEmtpy then '检查购物车是否为空
Response.Write(0)
else
Response.Write(myprice(1)) 
end if 
%></span>
<input type="button" value="去结算" style="margin-left:10px;" οnclick="window.location.href='order1.asp';" />
</p>

  相关解决方案