![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Hi, I display my shopping cart on this page below is the code Code: <%
arrCart = Session("Cart")
CART_COLUMNS = 9
Const cartProduct_Id = 0
Const cartSub_Item = 1
Const cartProduct_Code = 2
Const cartSize = 3
Const cartColor = 4
Const cartLogo = 5
Const cartPrice = 6
Const cartQty = 7
Const cartConsolidated = 8
finalstate=Trim(Request.Form("state"))
finalcity=Trim(Request.Form("city"))
order_Id=Trim(Request.Form("order_Id"))
Customerid=Trim(Request.Form("Customerid"))
%>
<head>
<title>Order Review</title>
</head>
<body>
<form name="frm1" method="post" action="submit.asp" onsubmit="return formCheck(this);">
<h1>Order Review</h1>
<fieldset>
<legend>Order Summary</legend>
<br/>
<%
Function CartExists()
MyRow = 0
For i = LBound(arrCart,2) to UBound(arrCart,2)
If arrCart(8,i) <> "" then
isCartItem= True
End if
Next
If isCartItem then
CartExists= true
Else
CartExists=False
End if
End Function
If CartExists() Then
%>
<table>
<thead>
<tr>
<th></th>
<th>Product Name</th>
<th>Size</th>
<th>Color</th>
<th>Logo</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<%
for i = LBound(arrCart, 2) to UBound(arrCart, 2)
if arrCart(cartConsolidated,i) <> "" then
total=arrCart(cartPrice, i) * int(arrCart(cartQty, i))
subtotal=subtotal+ total
Set rsselect1 = Server.CreateObject("adodb.RecordSet")
strselect1="SELECT Price FROM Shipping_Fees WHERE " & subtotal & " BETWEEN Start_Amount AND End_Amount"
rsselect1.Open strselect1,Conn, 2, 2
Price1=rsselect1("Price")
%>
<tr>
<td></td>
<td><%=arrCart(cartSub_Item, i)%></td>
<td><%=arrCart(cartSize, i) %></td>
<td><%=arrCart(cartColor, i) %></td>
<td><%=arrCart(cartLogo , i)%></td>
<td><%=FormatCurrency(arrCart(cartPrice , i))%></td>
<td align="center"><%=arrCart(cartQty , i) %></td>
<td><%=FormatCurrency(total)%></td>
</tr>
<%
end if
Next
%>
<tr>
<td colspan="6" align="right">Sub Total:</td>
<td colspan="2" align="right"><%=FormatCurrency(subtotal)%></td>
</tr>
<%
if finalstate= "Boston" then
Select case(finalcity)
Case "boston" , "BOSTON"
salestax="0.074"
salestax=salestax *subtotal
salestax = formatnumber(salestax,2)
Case Else
salestax="0.029"
salestax=salestax * subtotal
salestax = formatnumber(salestax,2)
End select
else
salestax="0.00"
End if
%>
<tr>
<td colspan="6" align="right">Taxes:</td>
<td colspan="2" align="right"><%=FormatCurrency(salestax)%></td>
</tr>
<%
salesamount=salestax + subtotal
%>
<tr>
<td colspan="6" align="right">Sales Amount:</td>
<td colspan="2" align="right"><%=FormatCurrency(salesamount)%></td>
</tr>
<tr>
<%
mainPrice1 = FormatCurrency(Price1)
%>
<td colspan="6" align="right">Shipping Fees:</td>
<td colspan="2" align="right"><%=mainPrice1%></td>
</tr>
<%
Finaltotal =salesamount+ Price1
%>
<tr>
<td colspan="6" align="right">Total</td>
<td colspan="2" align="right"><%=FormatCurrency(Finaltotal)%></td>
</tr>
</table>
<input type="submit" class="button" value="Submit" /></p>
<%
End If
%>
<input type="hidden" name="finalstate" id="finalstate" value="<%=finalstate%>"/>
<input type="hidden" name="finalcity" id="finalcity" value="<%=finalcity%>"/>
<input type="hidden" name="order_Id" id="order_Id" value="<%=order_Id%>"/>
<input type="hidden" name="Customerid" id="Customerid" value="<%=Customerid%>"/>
</body>
</html>
here is the code for it Code: <%
arrCart = Session("Cart")
CART_COLUMNS = 9
Const cartProduct_Id = 0
Const cartSub_Item = 1
Const cartProduct_Code = 2
Const cartSize = 3
Const cartColor = 4
Const cartLogo = 5
Const cartPrice = 6
Const cartQty = 7
Const cartConsolidated = 8
finalstate=Trim(Request.Form("state"))
finalcity=Trim(Request.Form("city"))
order_Id=Trim(Request.Form("order_Id"))
Customerid=Trim(Request.Form("Customerid"))
strdetails ="select * from Order_Details;"
Set rsorderdetails = Server.CreateObject("ADODB.Recordset")
With rsorderdetails
.Source="Order_Details"
.CursorType = 2
.LockType = 3
End With
rsorderdetails.Open strdetails, Conn
for i = 0 to ubound(arrCart,2)
if arrCart(0,i) <> "" then
rsorderdetails.AddNew
rsorderdetails("Order_Id") = order_Id
rsorderdetails("Customer_Id") = Customerid
rsorderdetails("Product_Name") = arrCart(1,i)
rsorderdetails("Product_Code") = arrCart(2,i)
rsorderdetails("Size") = arrCart(3,i)
rsorderdetails("Color") = arrCart(4,i)
rsorderdetails("Logo") = arrCart(5,i)
rsorderdetails("Price") = arrCart(6,i)
rsorderdetails("Quantity") = arrCart(7,i)
rsorderdetails.Update
End if
Next
rsorderdetails.Close
set rsorderdetails = nothing
%>
<fieldset>
<legend><h3>Order Summary</h3></legend>
<%
Function CartExists()
MyRow = 0
For i = LBound(arrCart,2) to UBound(arrCart,2)
If arrCart(8,i) <> "" then
isCartItem= True
End if
Next
If isCartItem then
CartExists= true
Else
CartExists=False
End if
End Function
If CartExists() Then
%>
<table width="720">
<thead>
<tr>
<th></th>
<th>Product</th>
<th>Size</th>
<th>Color</th>
<th>Logo</th>
<th>Price</th>
<th style="text-align:center;">Quantity</th>
<th style="text-align:right;">Total</th>
</tr>
</thead>
<%
for i = LBound(arrCart, 2) to UBound(arrCart, 2)
if arrCart(cartConsolidated,i) <> "" then
total=arrCart(cartPrice, i) * int(arrCart(cartQty, i))
subtotal=subtotal+ total
Set rsselect1 = Server.CreateObject("adodb.RecordSet")
strselect1="SELECT Price FROM Shipping_Fees WHERE " & subtotal & " BETWEEN Start_Amount AND End_Amount"
rsselect1.Open strselect1,Conn, 2, 2
Price1=rsselect1("Price")
%>
<tr>
<td></td>
<td><%=arrCart(cartSub_Item, i)%></td>
<td><%=arrCart(cartSize, i) %></td>
<td><%=arrCart(cartColor, i) %></td>
<td><%=arrCart(cartLogo , i)%></td>
<td><%=FormatCurrency(arrCart(cartPrice,i))%></td>
<td align="center"><%=arrCart(cartQty , i) %></td>
<td style="text-align:right;"><%=FormatCurrency(total)%></td>
</tr>
<%
end if
Next
%>
<tr>
<td colspan="6" align="right">Sub Total:</td>
<td colspan="2" align="right"><%=FormatCurrency(subtotal)%></td>
</tr>
<%
if finalstate= "Boston" then
Select case(finalcity)
Case "boston" , "BOSTON"
salestax="0.074"
salestax=salestax *subtotal
salestax = formatnumber(salestax,2)
Case Else
salestax="0.029"
salestax=salestax * subtotal
salestax = formatnumber(salestax,2)
End select
else
salestax="0.00"
End if
%>
<tr class="evenrow">
<td colspan="6" align="right">Taxes:</td>
<td colspan="2" align="right"><%=FormatCurrency(salestax)%></td>
</tr>
<%
salesamount=salestax + subtotal
%>
<tr class="oddrow">
<td colspan="6" align="right">Sales Amount:</td>
<td colspan="2" align="right"><%=FormatCurrency(salesamount)%></td>
</tr>
<tr class="evenrow">
<%
dim mainPrice1
mainPrice1 = FormatCurrency(Price1)
%>
<td colspan="6" align="right">Shipping Fees:</td>
<td colspan="2" align="right"><%=mainPrice1%></td>
</tr>
<%
Dim mainFinaltotal
Finaltotal =salesamount+ Price1
%>
<tr class="oddrow">
<td colspan="6" align="right">Total</td>
<td colspan="2" align="right"><%=FormatCurrency(Finaltotal)%></td>
</tr>
</table>
<%
End if
%>
but when i hit submit the subtotal is not displayed right it doubles the value So when the cart is displayed for first time the sub total is 16 when you submit the page the sub total becomes 32 can someone tell me why its doing like that |
| Sponsored Links |
|
#2
| ||||
| ||||
| is all of this on one page? or do you go to a second page when submit is hit? if on the same page, you are using the same variable subtotal for both. since you never reset subtotal to 0 before starting the after submitted code, it will double itself. you can try adding the bolded to that part of the code Code: <%subtotal = 0 for i = LBound(arrCart, 2) to UBound(arrCart, 2) if arrCart(cartConsolidated,i) <> "" then total=arrCart(cartPrice, i) * int(arrCart(cartQty, i)) subtotal=subtotal+ total
__________________ Quote of the Month: Regret: It hurts to admit when you make mistakes - but when they're big enough, the pain only lasts a second. Questions to Ponder: Could it be that all those trick-or-treaters wearing sheets aren’t going as ghosts but as mattresses? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright © 2008 sbenj69 |
| The Following User Says Thank You to mehere For This Useful Post: | ||
Rebelle (August 22nd, 2008) | ||
|
#3
| |||
| |||
| mehere, thanks for ur reply. No its on a different page. u see the shopping cart first and then hit submit and it goes to a different page and data is added and then the shopping cart is displayed it only happens for the sub total it doubles the amount I have seen the code 6 times and i dont know why its doing it any idea todd |
|
#4
| ||||
| ||||
| i want to test something ... add the bolded lines (on the page after the submit) and tell me what it gives you Code: response.Write("Subtotal is: " & subtotal)
response.end
for i = LBound(arrCart, 2) to UBound(arrCart, 2)
|
|
#5
| |||
| |||
| good morning mehere, when i do a response.write it gives me a value of 4 which i right I added a product whose price was $2.00 but i add 2 as qty so the price should be 4 so its right over there can u tell me what i am doing wrong |
|
#6
| |||
| |||
| I got it mehere i had to make subtotal as 0 let me test it and see if there are any problems |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|