<%
Option Explicit
If IsEmpty(Request.Form("CalculateShipping")) Then
  Response.Redirect "./shopping_cart.asp"
End If
Dim conn
Dim RSFooter
Dim RSTotal
Dim RSTotalWeight
Dim RSShipping
Dim ShippingPrice
Dim RSTaxes
set conn = server.createobject ("adodb.connection")
conn.open "ASPBook", "sa", "nep2tune"
conn.execute "insert into ASPSessionPages (SessionID, PageName) values (" _
  & Session("SessionID") & ", " _
  & "'Tax')"
set RSFooter = conn.execute("select BriefText from ASPPageText " _
  & "where PageName = 'Footer'")
set RSTotalWeight = conn.execute("SELECT Sum(ASPSessionItems.Quantity * " _
  & "ASPProducts.Weight) as TotalWeight " _
  & "FROM ASPSessionItems INNER JOIN ASPProducts ON " _
  & "ASPSessionItems.ProductID = ASPProducts.ProductID " _
  & "WHERE ASPSessionItems.SessionID = " & Session("SessionID"))
set RSShipping = conn.execute("Select MinimumShipping, PerPoundShipping, " _
  & "BaseRate From ASPShippingCharge where " _
  & "ShippingChargeID = " & Request.Form("Location"))
ShippingPrice = (RSTotalWeight("TotalWeight") * RSShipping("PerPoundShipping")) _
  + RSShipping("BaseRate")
If ShippingPrice < RSShipping("MinimumShipping") Then
  ShippingPrice = RSShipping("MinimumShipping")
End If
conn.execute "update ASPSessions set ShippingTotal = " & ShippingPrice _
  & "Where SessionID = " & Session("SessionID")
set RSTotal = conn.execute("select Sum(ItemPrice) as TheTotal from " _
  & "ASPSessionItems where SessionID = " & Session("SessionID"))
set RSTaxes = conn.execute("select Location, TaxRate from ASPTaxTable " _
  & "order by Location")
%>
