Forums

ASP

This topic is locked

display value based on session value.

Posted 21 Jan 2005 13:59:22
1
has voted
21 Jan 2005 13:59:22 Simon Bloodworth posted:
I am hitting a bit of a wall here.

I have an online store that works fine but am have difficulty with the delivery charge.

What i have done is create this code to set delivery amounts:

<%
Dim intPost1, intPost2, intPost3

intPost1 = formatcurrency(2.99)
intPost2 = formatcurrency(5.99)
intPost3 = formatcurrency(10)
%>

I then have this bit of code:

<%
If Session("delivery" < 2 Then
response.write intPost1
ElseIf Session("delivery" <= 5 Then
response.write intPost2
ElseIf Session("delivery" > 5 Then
response.write intPost3

End If
%>

The idea is that the session value holds what is being added to it from the product and then that value is used against the output code above.

It isnt working, on the first attempt it works fine, the delivery value set on a product gets carried though to the cart page and it all displays fine, but when they continue shopping and maybe choose an item that has a lower delivery charge it uses that and doesnt maintain the previous value as well.

Is it just a problem with the session and the fact that it is only holding one value at a time?

Sorry its a bit long winded but any help please would be great?

Regards

Simon

Replies

Replied 21 Jan 2005 17:27:24
21 Jan 2005 17:27:24 Lee Diggins replied:
Hi Simon

Sessions will only hold one value but if you had more than one you wanted to store in a session you could separate the values with a comma or something and extract the values by reversing the process. Do you want the session to only hold the highest shipping value?

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 21 Jan 2005 17:35:20
21 Jan 2005 17:35:20 Simon Bloodworth replied:
Thanks for the reply Lee.

That is exactly it. I need the session to hold and keep the highest value, even if they can continue and choose an item with a lower postage value.

Any suggestions?

Many thanks for your help.
Replied 21 Jan 2005 17:42:51
21 Jan 2005 17:42:51 Lee Diggins replied:
How do you assign the shipping value to the session variable?

Something like this maybe:

If Session("delivery" < varAssignment Then
Session("delivery" = varAssignment
End If

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 21 Jan 2005 18:04:50
21 Jan 2005 18:04:50 Simon Bloodworth replied:
Each item in the store has its own weight category, and each weight corresponds to a shipping charge.

I.e :

< 2Kg = 2.99

>2kg<5kg = 5.99

>5kg = 10

So if the customer buys 2 items, one that weighs 2kg and one that weighs 5kg - i need for it to take the heighest weight and charge that amount.


So then i had this bit of code:

<%
If Session("delivery" < 2 Then
response.write intPost1
ElseIf Session("delivery" >2< 5 Then
response.write intPost2
ElseIf Session("delivery" > 5 Then
response.write intPost3

End If
%>

Which works fine if it is only one item, but if they buy another item, and its weight is lower than the first, it reverts to the delivery charge for that, where as i would like it to keep the heighest or at least add them together so the higher postage is always used.

Hope that is clear, not the greatest person at explaining things.

many thnaks for your help

regards

simon
Replied 21 Jan 2005 18:19:16
21 Jan 2005 18:19:16 Lee Diggins replied:
I understand you Simon, but what code do you use to assign the delivery amount to the session variable, you have code like Session("delivery" = Request.Form("blah" or something similar.

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 21 Jan 2005 18:38:56
21 Jan 2005 18:38:56 Simon Bloodworth replied:
Oh, sorry Lee.

The delivery amount comes through as a form variable.

cheers
Replied 21 Jan 2005 18:48:10
21 Jan 2005 18:48:10 Lee Diggins replied:
Hi Simon

Change varAssignment to your form item/variable:

If Session("delivery" < varAssignment Then
Session("delivery" = varAssignment
End If

Response.Write(Session("delivery")

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 21 Jan 2005 19:00:25
21 Jan 2005 19:00:25 Simon Bloodworth replied:
sorry being really thick here but what should varAssignment be equal to?
Replied 22 Jan 2005 22:30:38
22 Jan 2005 22:30:38 Simon Bloodworth replied:
Got what you mean but it is not remembering the highest value - keeps taking the value last chosen - any ideas.

and once again thanks for your help.
Replied 24 Jan 2005 11:31:36
24 Jan 2005 11:31:36 Lee Diggins replied:
Hi Simon

Can you post the code that sets the Session("delivery" value?

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 24 Jan 2005 19:57:33
24 Jan 2005 19:57:33 Simon Bloodworth replied:
<%= session("delivery" = request.form("delivery" %>

hope that helps
Replied 24 Jan 2005 21:28:41
24 Jan 2005 21:28:41 Lee Diggins replied:
Hi Simon

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>&lt;%= session("delivery" = request.form("delivery" %&gt;<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Not sure what you're meaning to do here.

Try this:

<pre id=code><font face=courier size=2 id=code>&lt;%
If CDbl(Session("delivery") &lt; CDbl(Request.Form("delivery") Then
Session("delivery" = CDbl(Request.Form("delivery")
End If

Response.Write(Session("delivery")
%&gt;</font id=code></pre id=code>

I've include the CDbl function as you're working with money datatype.

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 24 Jan 2005 21:51:13
24 Jan 2005 21:51:13 Simon Bloodworth replied:
cheers - i'll give it a go.

Many thanks for all your help

Reply to this topic