Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-03-2007, 05:53 PM
New kid on the block
 
Join Date: Mar 2007
Location: KL
Posts: 1
Rep Power: 0
angie_wnv is on a distinguished road
please help...shopping cart passing values to another page

Dear

May I know to post the shopping cart's data to another page. the code i take from ASP 101 Sample Code. I can pass the Total amount via <a href="onlineOrder.asp?total=<%=sTotal%>">. How about I wanna pass these product name, quantity and description.
Because i try <a href="onlineOrder.asp?qty=<%=aParameters(1)%>"> only can get the latest data. Please guide me to do. thanks.


For example the shopping cart page:
<% Sub AddItemToCart(iItemID, iItemCount)
If dictCart.Exists(iItemID) Then
dictCart(iItemID) = dictCart(iItemID) + iItemCount
Else
dictCart.Add iItemID, iItemCount
End If
Response.Write iItemCount & " of product " & iItemID & " have been added to your cart.

" & vbCrLf
End Sub

Sub RemoveItemFromCart(iItemID, iItemCount)
If dictCart.Exists(iItemID) Then
If dictCart(iItemID) <= iItemCount Then
dictCart.Remove iItemID
Else
dictCart(iItemID) = dictCart(iItemID) - iItemCount
End If
Response.Write iItemCount & " of product " & iItemID & " have been removed from your cart.

" & vbCrLf
Else
Response.Write "Couldn't find any of that item your cart.

" & vbCrLf
End If
End Sub

Sub ShowItemsInCart()
Dim Key
Dim aParameters ' as Variant (Array)
Dim sTotal, sShipping

%>
<style type="text/css">
<!--
.style1 {
color: #CCCCCC;
font-weight: bold;
}
.style2 {color: #FFFFFF}
.style3 {color: #FFFFFF; font-weight: bold; }
-->
</style>

<TABLE Border=0 CellPadding=3 CellSpacing=1 width='475'>
<TR bgcolor="#993300">
<TD width="62" align="center" class="style3">Products No </TD>
<TD width="77" align="center" class="style3">Description</TD>
<TD width="58" align="center" class="style3">Quantity</TD>
<TD width="101" align="center" class="style3">Remove Item From Cart</TD>
<TD width="68" align="center" class="style3">Price<br />
(USD)</TD>
<TD width="66" align="center" class="style3">Totals<br />
(USD)</TD>
</TR>
<%
sTotal = 0
For Each Key in dictCart
aParameters = GetItemParameters(Key)
%>
<TR bgcolor="#FFFFCC">
<TD ALIGN="Center"><%= Key %></TD>
<TD ALIGN="Left"><%= aParameters(1) %></TD>
<TD ALIGN="Center"><%= dictCart(Key) %></TD>
<TD ALIGN="Left"><A HREF="./shopping.asp?action=del&item=<%= Key %>&count=1">Remove One</A><br /><A HREF="./shopping.asp?action=del&item=<%= Key %>&count=<%= dictCart(Key) %>">Remove All</A></TD>
<TD ALIGN="Right">USD $<%= aParameters(2) %></TD>
<TD ALIGN="Right">USD $<%= FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) %></TD>
</TR>
<%
sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2)))
Next

'Calculate shipping - you might want to pull this out into a function if your shipping
' calculations are more complicated then ours.
If sTotal <> 0 Then
sShipping = 0
Else
sShipping = 0
End If
sTotal = sTotal + sShipping
%>
<TR><TD COLSPAN=6 ALIGN="Right"> </TD></TR>
<TR>
<TD COLSPAN=5 ALIGN="Right"><B>Total (USD):</B></TD>
<TD ALIGN="Right">$<%= FormatNumber(sTotal,2) %></TD></TR>
</TABLE>
<%
End Sub

Sub ShowFullCatalog()
Dim aParameters ' as Variant (Array)
Dim I
Dim iItemCount ' Number of items we sell

iItemCount = 3
%>
<TABLE Border=0 CellPadding=3 CellSpacing=1 width='475'>
<TR bgcolor="#993300">
<TD width="100" align="center" class="style3">Products</TD>
<TD width="196" align="center" class="style3">Description</TD>
<TD width="66" align="center" class="style3">Price<br />(USD) </TD>
<TD width="74" align="center" class="style3">Purchase</TD>
</TR>
<%
For I = 1 to iItemCount
aParameters = GetItemParameters(I)
%>
<TR bgcolor="#FFFFCC">
<TD bgcolor="#FFFFFF"><IMG SRC="<%= aParameters(0) %>"></TD>
<TD><%= aParameters(1) %></TD>
<TD>USD$<%= aParameters(2) %></TD>
<TD align="center"><A HREF="./shopping.asp?action=add&item=<%= I %>&count=1">Add </A></TD>
</TR>
<%
Next 'I
%>
</TABLE>
<%
End Sub

Sub PlaceOrder()
Dim Key
Dim aParameters ' as Variant (Array)
Dim sTotal, sShipping

%>
<TABLE Border=0 CellPadding=3 CellSpacing=1 width='475'>
<TR bgcolor="#993300">
<TD width="92" align="center" class="style3">Products No </TD>
<TD width="123" align="center" class="style3">Description</TD>
<TD width="75" align="center" class="style3">Quantity</TD>
<TD width="65" align="center" class="style3">Price<br />(USD)</TD>
<TD width="72" align="center" class="style3">Totals<br />(USD) </TD>
</TR>
<%
sTotal = 0
For Each Key in dictCart
aParameters = GetItemParameters(Key)
%>
<TR bgcolor="#FFFFCC">
<TD ALIGN="Center"><%= Key %></TD>
<TD ALIGN="Left"><%= aParameters(1) %></TD>
<TD ALIGN="Center"><%= dictCart(Key) %></TD>
<TD ALIGN="Right">USD $<%= aParameters(2) %></TD>
<TD ALIGN="Right">$<%= FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) %></TD>
</TR>
<%
sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2)))
Next

'Calculate shipping - you might want to pull this out into a function if your shipping
' calculations are more complicated then ours.
If sTotal <> 0 Then
sShipping = 0
Else
sShipping = 0
End If
sTotal = sTotal + sShipping
%>
<TR><TD COLSPAN=5 ALIGN="Right"> </TD></TR>
<TR>
<TD COLSPAN=4 ALIGN="Right"><B>Total (USD):</B></TD>
<TD ALIGN="Right"><%= FormatNumber(sTotal,2) %></TD></TR>
<tr><td colspan="5"><a href="onlineOrder.asp?total=<%=sTotal%>&qty=<%= aParameters(1) %>&price=<%= aParameters(2) %>&key=<%= I %>" target="_parent">Register your detail</a></td></tr>
</TABLE>
<%
End Sub


Function GetItemParameters(iItemID)
Dim aParameters

Select Case iItemID
Case 1
aParameters = Array("Images/product/1.jpg", "product 1", "260")
Case 2
aParameters = Array("Images/product/2.jpg", "product 2", "700")
Case 3
aParameters = Array("Images/product/3.jpg", "product 3", "105")
Case 4 ' Not in use because we couldn't draw a pen in a few seconds!
aParameters = Array("Images/product/1.jpg", "ASP 101 Pen", "5.00")
End Select
' Return array containing product info.
GetItemParameters = aParameters
End Function
%>


<% ' ***** Begin the infamous runtime script *****
' Declare our Vars
Dim dictCart ' as dictionary
Dim sAction ' as string
Dim iItemID ' as integer
Dim iItemCount ' as integer

If IsObject(Session("cart")) Then
Set dictCart = Session("cart")
Else
' We use a dictionary so we can name our keys to correspond to our
' item numbers and then use their value to hold the quantity. An
' array would also work, but would be a little more complex and
' probably not as easy for readers to follow.
Set dictCart = Server.CreateObject("Scripting.Dictionary")
End If

sAction = CStr(Request.QueryString("action"))
iItemID = CInt(Request.QueryString("item"))
iItemCount = CInt(Request.QueryString("count"))
%>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR><TD>
<%

Select Case sAction
Case "add"
AddItemToCart iItemID, iItemCount
ShowItemsInCart
%>
</TD></TR>
<TR><TD ALIGN="right">
<A HREF="./shopping.asp?action=">Continue Shopping</A>
<A HREF="./shopping.asp?action=checkout">Checkout</A>

<%
Case "del"
RemoveItemFromCart iItemID, iItemCount
ShowItemsInCart
%>
</TD></TR>
<TR><TD ALIGN="right">
<A HREF="./shopping.asp?action=">Continue Shopping</A>
<A HREF="./shopping.asp?action=checkout">Checkout</A>

<%
Case "viewcart"
ShowItemsInCart
%>
</TD></TR>
<TR><TD ALIGN="right">
<A HREF="./shopping.asp?action=">Continue Shopping</A>
<A HREF="./shopping.asp?action=checkout&product1=<%= FormatNumber(sTotal,2) %>">Checkout</A>

<%
Case "checkout"
PlaceOrder
%>
</TD></TR>
<TR><TD ALIGN="left">


<%
Case Else ' Shop
ShowFullCatalog
%>
</TD></TR>
<TR><TD ALIGN="right"><br />
<A HREF="./shopping.asp?action=viewcart">View Cart Contents</A>
<%
End Select

Set Session("cart") = dictCart
%>
</TD></TR>
</TABLE>


In the "onlineOrder.asp" page
<html>
<%
Set dictCart = Session("cart")

dim total, qty, price

total = Request.QueryString("total")
qty = Request.QueryString("qty")
price = Request.QueryString("price")


%>
<body>
Products = <%=Server.HTMLEncode(qty)%>
Total =$<%=Server.HTMLEncode(total)%>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Have anybody here tried Shopping.com? limcs Revenue and Monetization 0 12-08-2006 12:27 AM
shopping cart clieza E-Commerce 3 11-06-2006 11:35 PM
Searching for shopping cart K-C E-Commerce 15 19-07-2005 09:55 PM
passing value nov8998 Website Programming 4 18-08-2004 11:15 AM
Free ASP shopping cart alvinhan E-Commerce 5 16-01-2003 01:23 PM



All times are GMT +8. The time now is 06:52 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60