21 users online (0 members and 21 guests)  


  Results 1 to 6 of 6

Related

  1. shopping cart with joomla    Forum: General Discussion
    Replies: 2
  2. shopping cart needed    Forum: General Discussion
    Replies: 7
  3. How do i make a shopping cart?    Forum: Website Scripts Forum
    Replies: 5
  4. shopping cart    Forum: PHP Forum
    Replies: 0
  1. #1
    wnv's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    1

    please Help..Shopping cart passing values to another pages

    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:

    Code:
    <% 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 
        ' If you are really going to use this sample this should probably be pulled from a DB 
        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 
    
    ' We implemented this this way so if you attach it to a database you'd only need one call per item 
    Function GetItemParameters(iItemID) 
    Dim aParameters ' Will contain 3 string values : image path, description, price 
                    ' However we need to keep price so it can be converted to a 
                    ' single for computation hence no currency symbol.  This array 
                    ' can also be expanded to contain any other information about the 
                    ' product that you might want to pull from the DB. 
        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 
    
    ' Get a reference to the cart if it exists otherwise create it 
    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 
    
    ' Get all the parameters passed to the script 
    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 action based on user input 
    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 
    
    ' Return cart to Session for storage 
    Set Session("cart") = dictCart 
    %> 
    </TD></TR> 
    </TABLE>
    In the "onlineOrder.asp" page

    Code:
    <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>
    Last edited by vinyl-junkie; 03-08-2007 at 08:29 AM. Reason: Added code tags

  2. #2
    ASPtech1.1's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2007
    Posts
    1

    Re: please Help..Shopping cart passing values to another pages

    The answer to your question is actually pretty simple. In order to pass more than one bit of information along, try this code:

    Code:
    <a href="onlineOrder.asp?total=<%=sTotal%>&qty="<%=aParameters(1)%>">
    Of course for Product Name and Description, you would continue to use & in the end of your string.

  3. #3
    David Albert's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    9

    Exclamation Re: please Help..Shopping cart passing values to another pages

    get your values on the other page with the help of session as follows:
    Session["total"] = txttotal.Text;
    Session["qty"] = txtqty.Text;
    Session["price"] = txtprice.Text;
    txttotal, txtqty and txtprice are the textboxes names from where you get values which will you pass to another page. Than on the other page get all the 3 values in a string as follows:
    string total=Session["total"].ToString();
    string qty=Session["qty"].ToString();
    string price=Session["price"].ToString();
    regards

  4. #4
    Ronan's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2007
    Location
    Santa Fe
    Posts
    16

    Cool Re: please Help..Shopping cart passing values to another pages

    Its an old post but someone may find this info usefull.

    To pass data from one page to another one you have 2 options: one by querystring and another one by session. Each one has different pro/cons.

    In the the cart I use - comersus - the session method is used when you want to hide the information or avoid the modification. and the querystring method is used in other parts, for example: passing the id of the item to be browsed.

  5. #5
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: please Help..Shopping cart passing values to another pages

    There are actually other ways as well including "POST"ing the data from one page to another and using cURL, but those Ronan mentioned are the simplest and the most common. Just don't think that you are too limited when developing.

  6. #6
    pyaramosam's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2015
    Posts
    1

    Re: please Help..Shopping cart passing values to another pages

    To pass data from one page to another one you have 2 options: one by querystring and another one by session. Each one has different pro/cons.

    _____________
    GuL



Tags for this Thread