<% Dim ShipMethod Dim ShipCost Dim ShippingMethods(50) Dim ShippingCount Dim CalculationType dim upsdbc const productcostfield="weight" ' set to other field if necessary '********************************************************************** ' Version 5.00 Demo Only Lookup Supported ' March 27, 2003 ' in shop$config.asp ' Const xShippingCalc="Lookup" fixed price lookup in database+delivery ' Const xShippingCalc="Weight" Calculate by weight + delivery ' Const xShippingCalc="Quantity" Calculate by Quantity ' Const xShippingCalc="WeightRange" 'lookup total weight+ delivery ' Const xShippingCalc="PriceRange" ' lookup by price range +delivery ' Const xShippingCalc="Product" ' shipping is unique to product(weight field has value) ' Const xShippingCalc="Fixed" ' const xshippingcalc="Other" ' ' other requires shiproutine to be filled in ' const xshippingcalc="QuantityRange" ' ' other requires shiproutine to be filled in ' Const xShippingcalc="Message" ' Free shipping over a certain amount ' Country based shipping '********************************************************************* ' Sub UpdateShippingSessionData() ' called from shop customer to process form and get shipping price Dim optionname Dim optionPrice dim rc SetSess "shipname", strshipname SetSess "shipcompany", strshipcompany SetSess "shipaddress", strshipaddress SetSess "shiptown", strshiptown SetSess "shipzip", strshipzip SetSess "shipstate", strshipstate SetSess "shipcountry", strshipcountry Setsess "shippingmessage","" ShipMethodType=Request.form("ShipMethodType") if shipmethodtype="" then shipmethodtype=getconfig("xfixedshippingmethod") end if SetSess("Shipmethodtype"),Shipmethodtype ParseOption ShipMethodType, ShipMethod, ShipCost SetSess "ShipMethod",Shipmethod If getconfig("Xcurrencysymbol")<>"" and Shipcost<>"" then shipcost=replace(shipcost,getconfig("xcurrencysymbol"),"") end if SetSess "smprice",ShipCost If ucase(getconfig("xshippingCalc"))="LOOKUP" then SetSess "ShipCalc","LOOKUP" DeliveryShippingCalc exit sub end if CalculateShipping ' all others handled differently if getconfig("xDeliveryShipping")="Yes" then DeliveryShippingCalc ' handle delivery shipping end if end sub ' Sub CalculateShipping Calculationtype=ucase(getconfig("xShippingCalc")) ' What type of calculation are we doing If Calculationtype="" then exit sub shopwriteerror "Only Lookup supported in demo" end sub Sub GetShippingDatabase '*************************************************** ' Read database and store dat in shippingmethods array '************************************************* Dim rsship Dim dbc Dim TempOption Dim TempPrice dim prevMethod shippingcount=0 prevmethod="" ShopOpenDatabase dbc Set rsship = Server.CreateObject ("ADODB.Recordset") SQL="Select * from shipmethods order by shipmethod" rsship.Open SQL, dbc, adOpenForwardOnly,adLockReadOnly, adCmdText Do While Not rsship.EOF TempOption = rsship("shipmethod") TempPrice=rsship("smprice") If getconfig("xdisplayprices")="No" then TempPrice="" end if if TempPrice<>"" then if TempPrice<>0 then TempOption= TempOption & " [" & formatnumber(TempPrice,getconfig("xdecimalpoint")) & "]" end if end if if TempOption<>PrevMethod then ShippingMethods(shippingcount)=TempOption PrevMethod=TempOption If ShippingCount=0 then If GetSess("Shipmethodtype")<>"" then shipmethodtype=Getsess("shipmethodtype") else ShipMethodType=ShippingMethods(0) ' set defaut method end if end if shippingcount=shippingcount+1 end if rsship.MoveNext Loop closerecordset rsship ShopCloseDatabase dbc end sub '************************************************* Sub LocateShippingRecord (Shipmethod) ' gets one shipping method from database dim shipsql Dim i ' Reread database record for a particular method ShopOpenDatabase dbc ShipSql="Select * from shipmethods where Shipmethod='" & shipmethod & "'" AddShippingCountry shipsql Set objRS = dbc.Execute(shipsql) If objRS.EOF Then Shipmethod = "Cannot locate shipping record
" & shipsql setsess "shipmessage",shipmethod Else lngshipmethodid = objrs("shipmethodid") strshipmethod = objrs("shipmethod") cursmprice = objrs("smprice") curshipbasecost = objrs("shipbasecost") curshipextracost = objrs("shipextracost") if isnull(curshipbasecost) then curshipbasecost=0 end if if isnull(curshipextracost) then curshipextracost=0 end if strshipother1 = objrs("shipother1") strshipother2 = objrs("shipother2") curshipcost2 = objrs("shipcost2") curshipcost1 = objrs("shipcost1") ShipCost=curSmprice End If closerecordset objrs ShopcloseDatabase dbc End Sub ' %>