<% '************************************************************** ' Software name: PowerEasy SiteWeaver ' Web: http://www.powereasy.net ' Copyright (C) 2005-2008 佛山市动易网络科技有限公司 版权所有 '************************************************************** Dim trs, rsProductList CartID = ReplaceBadChar(Trim(Request.Cookies("Cart" & Site_Sn)("CartID"))) If CartID = "" Or IsNull(CartID) Then CartID = MD5(Now() & Timer() & session.SessionID, 32) End If ProductID = Trim(Request("ProductID")) PresentID = Trim(Request("PresentID")) If IsValidID(ProductID) = False Then ProductID = "" End If If IsValidID(PresentID) = False Then PresentID = "" End If IsWholesale = PE_CLng(Request("IsWholesale")) Select Case Action Case "Add" If ProductID = "" Then FoundErr = True ErrMsg = ErrMsg & "
  • 请指定要购买的产品ID!
  • " Else ProductID = PE_CLng(ProductID) ProductList = SelectCart(CartID, 0) Set trs = Conn.Execute("select ProductID,ProductType,Stocks,OrderNum,EnableSale,EnableSingleSell,DependentProducts from PE_Product where ProductID=" & ProductID & "") If trs.BOF And trs.EOF Then FoundErr = True ErrMsg = ErrMsg & "
  • 找不到指定的商品!
  • " Else If trs("EnableSale") = False Then FoundErr = True ErrMsg = ErrMsg & "
  • 商品已经停止销售!
  • " End If If trs("EnableSingleSell") = False And FoundInArr(trs("DependentProducts"), ProductList, ",") = False Then FoundErr = True ErrMsg = ErrMsg & "
  • 此商品不能直接购买!请先购买本商品的从属商品后再购买本商品
  • " End If If trs("Stocks") - trs("OrderNum") <= 0 Then FoundErr = True ErrMsg = ErrMsg & "
  • 实在对不起,此商品已经暂时售罄!
  • " End If If trs("ProductType") = 4 Then FoundErr = True ErrMsg = ErrMsg & "
  • 促销商品不能直接购买!
  • " End If End If Set trs = Nothing End If If FoundErr = False Then Call AddToCart(CartID, ProductID, 1, 0) End If Case "Clear" Call DelCart(CartID) Case "Modify" Call ModifyCart Case "Payment" Call ModifyCart Response.Redirect "Payment.asp" End Select If FoundErr = True Then Call WriteErrMsg(ErrMsg, ComeUrl) Response.End End If Response.Cookies("Cart" & Site_Sn)("CartID") = CartID Response.Cookies("Cart" & Site_Sn).Expires = Date + 365 ProductList = SelectCart(CartID, 0) PresentList = SelectCart(CartID, 1) If ProductList = "" Then '如果购物车为空,转入提示界面 ShowTips_CartIsEmpty = XmlText_Class("ShowTips_CartIsEmpty", "



    您好!目前您的购物车中没有任何商品,是不是继续购物





    ") Else ShowTips_CartIsEmpty = "" End If strHtml = GetTemplate(ChannelID, 9, 0) Call ReplaceCommon Call ReplaceUserInfo strHtml = Replace(strHtml, "{$ShowTips_Login}", ShowTips_Login) strHtml = Replace(strHtml, "{$ShowTips_CartIsEmpty}", ShowTips_CartIsEmpty) strHtml = Replace(strHtml, "{$ShowCart}", ShowCart()) Response.Write strHtml Call CloseConn Sub ModifyCart() If IsWholesale = 0 Then Call DelCart(CartID) End If If ProductID = "" Then Response.Write "请指定ProductID!" Exit Sub End If Dim arrProductList Dim arrPresentList Dim trs, i arrProductList = Split(ProductID, ",") For i = 0 To UBound(arrProductList) dblAmount = Request("Amount_" & Trim(arrProductList(i))) If dblAmount = "" Then dblAmount = 1 Else dblAmount = PE_CDbl(dblAmount) End If If dblAmount <= 0 Then dblAmount = 1 Set trs = Conn.Execute("select ProductID,Stocks,OrderNum,EnableSale,EnableSingleSell,DependentProducts from PE_Product where ProductID=" & arrProductList(i) & "") If Not (trs.BOF And trs.EOF) Then If (trs("EnableSale") = True) And (trs("EnableSingleSell") = True Or (trs("EnableSingleSell") = False And FoundInArr(trs("DependentProducts"), ProductID, ",") = True)) And (trs("Stocks") - trs("OrderNum")) > 0 Then Call AddToCart(CartID, arrProductList(i), dblAmount, 0) End If End If Set trs = Nothing Next arrPresentList = Split(PresentID, ",") For i = 0 To UBound(arrPresentList) Call AddToCart(CartID, arrPresentList(i), 0, 1) Next End Sub %>