<% suB ShopProductdependent (count) on error resume next '************************************************************ ' Version 6.50 March 8, 2004 ' This routine displays the shopping cart and does recalculation ' if returnurl is passed, this routine returns back to that URL ' '******************************************************* Dim CurrentURL, i, returnurl, deparray dim dbc, fieldname, msg, productname, maxcartitems, catalogid, dfieldname maxcartitems=getconfig("xmaxcartitems") ReDim deparray(2,500) Dim scartitem, arrcart, deliveryarray, deliveryrequired scartItem = GetSess("CartCount") arrCart = GetSessA("CartArray") count=0 fieldname=getconfig("xproductdependentfield") if fieldname="" then exit sub shopopendatabaseP dbc ' go through all products For i = 1 to scartItem catalogid=arrCart(cproductid,i) productname=arrCart(cproductname,i) CheckDependent catalogid, dbc, count,fieldname, deparray next shopclosedatabase dbc If count>0 then SetSess "depCount", count SetSessA "Deparray", deparray ' for i = 0 to count-1 ' debugwrite "0=" & deparray(0,i) ' debugwrite "1=" & deparray(1,i) ' next else SetSess "depCount", "" end if end sub '************************************************************************* ' see if product depdendent is necessary ' 1,2,(1,3,4) '*********************************************************************** sub CheckDependent (catalogid, dbc, count,dfieldname, deparray) dim rs, sql, products, requiredproduct, rc, listcount, productid dim productarray(500), productcount products="" sql="select * from products where catalogid=" & catalogid set rs=dbc.execute(sql) if not rs.eof then products=rs(dfieldname) if isnull(products) then products="" end if closerecordset rs if products="" then exit sub listcount=0 parserecord products,productarray, productcount,"," do while listcount 0 then CheckDeparray deparray, requiredproduct, count, rc if rc>0 then AddToDependentList catalogid, requiredproduct, deparray, count end if end if listcount=listcount+1 end if loop end sub '********************************************************************************* ' list like (7,8,9) '******************************************************************************** sub handleproductlist (catalogid, productid,productarray, productcount,deparray, count, listcount) dim sublist(50),sublistcount, finished, char, requiredproduct, rc sublistcount=0 finished=false char=left(productid,1) if char<>"(" then exit sub ' garbage productid=replace(productid,"(","") sublist(sublistcount)=clng(productid) sublistcount=sublistcount+1 listcount=listcount+1 do while listcount 0 then AddToDependentList catalogid, requiredproduct, deparray, count end if next end sub sub FindDependentProduct (productid, rc) dim i dim scartitem, arrcart, catalogid scartItem = GetSess("CartCount") arrCart = GetSessA("CartArray") For i = 1 to scartItem catalogid=arrCart(cproductid,i) if productid=clng(catalogid) then rc=0 exit sub end if next rc=4 end sub ' Sub ShopDependentMessage(msg) url="shopdependentdisplay.asp" mylink="" & getlang("LangCommonView") & "" dim url, mylink msg=Getlang("langdependenterror") & "
" msg=msg & mylink & "
" end sub ' Sub CheckDeparray (deparray, requiredproduct, count, rc) dim i, lreq rc=4 lreq=clng(requiredproduct) if count=0 then exit sub for i = 0 to count-1 If lreq=clng(deparray(1,i)) then rc=0 exit sub end if next end sub sub AddToDependentList (catalogid, requiredproduct, deparray, count) 'debugwrite " dding to dependent=" & requiredproduct deparray(0,count)=catalogid ' product that has dependency deparray(1,count)=requiredproduct count=count+1 end sub %>