<% Sub CalculateHandling (subtotal, total, shippingcost, handling) '*************************************************************** ' Version 6.50 ' This routine calculates handling fee for VP-ASP ' Inputs are ' subtotal - price of of products order ' total - price including shipping ' shippingcost cost of shipping ' handling this value needs to be set and returned ' Dec 7, 2006 add hnadling cost on sub product '***************************************************************** Handling=0 If getconfig("xhandlingPrice")<>"" then Handling=getconfig("xhandlingPrice") end if If getconfig("xhandlingbyproduct")<>"" then Calculatehandlingbyproduct handling end if end sub ' '************************************************************************ ' read product record. If there is a handling cost then use it ' If also have xhandinlngcombine and it is a sub product ' get the handling cost of the parent product and add to cost '*********************************************************************** Sub Calculatehandlingbyproduct (handling) dim handlingfield handlingfield=getconfig("xhandlingbyproduct") Dim productname, quantity, price, handlingdbc dim scartitem, arrcart, productid, productcode, handlingforitem dim handlingamount 'VP-ASP 6.50 - parent/child handling costs dim parenthandling Dim i dim productql dim rsitem ' ShopOpenDatabaseP handlingDbc scartItem = getsess("CartCount") ' number of products arrCart = getsessa("CartArray") For i = 1 to scartItem productid=arrCart(cProductid,i) productcode=arrCart(cProductCode,i) productname= arrCart(cProductname,i) quantity=arrCart(cQuantity,i) Price=arrCart(cUnitPrice, i) productql="select * from products where catalogid=" & productid Set rsItem = handlingdbc.execute(Productql) handlingforitem=0 If Not rsItem.EOF Then 'VP-ASP 6.50 - parent/child handling costs handlingamount=0 if not isnull(rsitem(handlingfield)) then handlingamount=rsitem(handlingfield) handlingamount=csng(handlingamount) handlingforItem=Quantity*handlingamount end if 'VP-ASP 6.50 - parent/child handling costs ' get parent handling cost Getparenthandlingcost handlingdbc,rsitem, parenthandling, handlingfield ' It is easy if we are combining them If Getconfig("xhandlingcombine")="Yes" then handlingamount=handlingamount+parenthandling else If handlingamount=0 then handlingamount=parenthandling ' parent take prference end if end if ' regardless of where we got them not calculate the current amount handlingforItem=Quantity*handlingamount end if handling=handling+handlingForItem closeRecordset rsitem Next ShopCloseDatabase handlingdbc end sub '*************************************************************************** 'VP-ASP 6.50 - parent/child handling costs ' is this product has a parent product, then get parent product handling cost '*************************************************************************** sub Getparenthandlingcost (handlingdbc,rsitem, parenthandling, handlingfield) dim productsql, rs parenthandling=0 dim subcatalogid, highercatalogid highercatalogid=rsitem("highercatalogid") If isnull(highercatalogid) then exit sub If highercatalogid=0 then exit sub productsql="select * from products where catalogid=" & highercatalogid Set rs = handlingdbc.execute(Productsql) If Not rs.EOF Then if not isnull(rs(handlingfield)) then parenthandling=rs(handlingfield) parenthandling=csng(parenthandling) end if end if closerecordset rs end sub %>