<%
' showcart.asp
' Displays the shopping cart.

Option Explicit
Dim showsearch, showcart, showcheckout, showany
showsearch=TRUE
showcart=FALSE
showcheckout=TRUE
showany=TRUE

Dim Item
Dim ProductCode(20), Description(20), Price(20), Title(20), ShortDescription(20), Expiration(20)

Dim ShowCartConn, MySQL, cmd, RecSet, i
Dim ItemsFound, DotPos, Dot2Pos, TotalCost, TotalShipping

' Get cart from cookie
' Loop through the cookie collection.
ItemsFound = 0
Set ShowCartConn = Server.CreateObject("ADODB.Connection")
ShowCartConn.Open Application("dsn")
For Each Item in Request.Cookies
	If (InStr(Item,".name") = 0) and (InStr(Item,".price") = 0) and (InStr(Item,"CART") > 0) Then
		'This is to skip over product name and price cookies. We'll rely on the database for that.
		' Search for it.
		mySQL = "sp_findproduct4sale '" & Mid(Item,5,45) & "'"
		Set Cmd = Server.CreateObject("ADODB.Command")
		Cmd.ActiveConnection = ShowCartConn
		Cmd.CommandText = mySQL
		Set RecSet = Server.CreateObject("ADODB.RecordSet")
		RecSet.Open Cmd, ,0,1
		If RecSet.EOF Then
		Else
			ItemsFound = ItemsFound + 1
			ProductCode(ItemsFound) = Mid(Item,5,45)
			Dot2Pos = InStr(DotPos+1, Item, ".")
			Description(ItemsFound) = RecSet.Fields("Description")
			If Len(Description(ItemsFound))>150 Then
				Description(ItemsFound) = Left(Description(ItemsFound),150) & "<b> ...</b>"
			End If
			Price(ItemsFound) = RecSet.Fields("Price")
			Title(ItemsFound) = RecSet.Fields("title")
			Expiration(itemsFound) = RecSet.Fields("expiration")
			ShortDescription(ItemsFound) = RecSet.Fields("subtitle")
		End If
		RecSet.Close
	End If
Next
Set RecSet = Nothing
ShowCartConn.Close
Set ShowCartConn = Nothing

%>


<html>
<head>
<title>Shopping Cart</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #INCLUDE VIRTUAL="/asp/inc/header.asp" -->
<TABLE cellSpacing=0 cellPadding=3 width=600 align=center border=0 bordercolor="#FFFFFF">
  <TR bgcolor="#FF99FF" bordercolor="#FFFFFF"> 
    <TD bgcolor="#FFCCFF"><font face="Arial, Helvetica, sans-serif" size="4"><b><font size="3">Shopping 
      Cart</font></b></font><BR>
    </TD>
    <TD bgcolor="#FFCCFF"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><a href="/asp/buy/checkout.asp">Checkout</a></font></div>
    </TD>
  </TR>
</TABLE>
<TABLE cellSpacing=1 cellPadding=0 width=600 align=center border=0>
<% If ItemsFound=0 Then %>
 <tr>
    <td bgcolor="#FFCCFF">
      <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><br>
        You currently don't have anything in your shopping cart. Why don't you 
        check out the <a href="../products/store.asp">Setsuko.com Cute Store</a> 
        and add something?<br>
        &nbsp; </b></font></div>
    </td>
  </tr>
<% Else %>
  <TR bgcolor="#e9e9e9"> 
    <TD width=249 bgcolor="#FFCCFF"><font face="Arial, Helvetica, sans-serif" size="2"><b>Product</b><BR>
      <IMG height=1 
      src="/images/spacer.gif" width=160></font></TD>
    <TD width=346 bgcolor="#FFCCFF"><font face="Arial, Helvetica, sans-serif" size="2"><B>Description</B><BR>
      <IMG height=1 
      src="/images/spacer.gif" width=300></font></TD>
    <TD width=71 bgcolor="#FFCCFF"><font face="Arial, Helvetica, sans-serif" size="2"><B>Price</B><BR>
      <IMG height=1 
      src="/images/spacer.gif" width=70></font></TD>
    <TD class=maincolor align=middle width=55 bgcolor="#FFCCFF"><font face="Arial, Helvetica, sans-serif" size="2"><B>Remove</B><BR>
      <IMG height=1 
      src="/images/spacer.gif" width=50></font></TD>
  </TR>
 <% End If %>
  <% 
TotalCost = 0
TotalShipping = 0
For i = 1 to ItemsFound
	TotalCost = TotalCost + Price(i)
	TotalShipping = TotalShipping + Application("USShippingRate")
%>
  <TR bgColor=#CCCCFF> 
    <TD vAlign=top width="249"><font size="2" face="Arial, Helvetica, sans-serif"><FONT 
      color=black><a href="../products/prodinfo.asp?p=<%=ProductCode(i)%>"><b><%=Title(i)%></b></a><br>
      <%=ShortDescription(i)%></FONT><BR>
      </font></TD>
    <TD vAlign=top width="346"><font size="2" face="Arial, Helvetica, sans-serif"> 
      <%=Description(i)%><BR>
      </FONT></TD>
    <TD vAlign=top align=right width="71"><font face="Arial, Helvetica, sans-serif" size="2">$<%=FormatNumber(Price(i),2)%></font></TD>
    <TD vAlign=top align=middle width="55"> <a href="delcart.asp?remove=<%=ProductCode(i)%>"><font face="Arial, Helvetica, sans-serif" size="2">Remove</font></a></TD>
  </TR>
  <% Next %>

</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=600 align=center border=0>
  <TR> 

    <TD vAlign=top align=right width=600> 
      <TABLE cellSpacing=1 cellPadding=3 width=100% border=0>
        <TR bgColor=#FFCCFF> 
          <TD align=right width=210 height=30>&nbsp;</TD>
          <TD align=right width=309 height=30><font  face="Arial, Helvetica, sans-serif" size="2"><B>MERCHANDISE 
            SUBTOTAL</B></font><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;&nbsp;</font></TD>
          <TD align=right width=57><font  face="Arial, Helvetica, sans-serif" size="2"><B>$<%=FormatNumber(TotalCost,2)%></B></font></TD>
        </TR>
        <TR bgColor=#f5f5f5> 
          <TD align=right height=30 bgcolor="#FFCCCC" width="210"> 
            <div align="center"><br>
              <form name="form2" method="post" action="/asp/buy/checkout.asp">
                <font face="Arial, Helvetica, sans-serif"><b> 
                <input type="submit" name="Submit" value="Check Out">
                </b></font> 
              </form>
            </div>
          </TD>
          <TD align=right height=30 bgcolor="#FFCCCC" width="309"><font face="Arial, Helvetica, sans-serif" size="2"><B>Shipping 
            and Handling</B>&nbsp;&nbsp;<BR>
            <FONT class=details>U.S. Destinations only</FONT>&nbsp;&nbsp;</font></TD>
          <TD align=right bgcolor="#FFCCCC" width="57"><B><font face="Arial, Helvetica, sans-serif" size="2">$<%=FormatNumber(TotalShipping,2)%></font></B></TD>
        </TR>
        <TR bgColor=#FFCCFF> 
          <TD align=right height=30 width="210">&nbsp;</TD>
          <TD align=right height=30 width="309"><font  face="Arial, Helvetica, sans-serif" size="2"><B>ESTIMATED 
            TOTAL</B></font><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;&nbsp;</font></TD>
          <TD align=right width="57"><font  face="Arial, Helvetica, sans-serif" size="2"><B>$<%=FormatNumber(TotalCost+(TotalCost*Application("TaxRate"))+TotalShipping,2)%></B></font></TD>
        </TR>
         
      </TABLE>
    </TD>
  </TR>
  <TR> 
    <TD vAlign=top> </TD>
  </TR>

</TABLE>
<!-- #INCLUDE VIRTUAL="/asp/inc/footer.asp" -->
<br>
</BODY></HTML>


