homepage Welcome to WebmasterWorld Guest from 54.235.36.164
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Classic ASP shopping cart help
Classic ASP shopping cart help
abidshahzad4u




msg:3960916
 9:59 am on Jul 28, 2009 (gmt 0)

Hi to all

I'm working on classic ASP site and I have to add Shopping Cart functionality to it.

I have to add up to 5 values in to the Shopping Cart item.

How can I do this. I need some Idea like Scripting.Dictionary objects. As Scripting.Dictionary is able to store only pair per item. My cart have four custom fields.

Please help?

 

Ocean10000




msg:3961023
 1:50 pm on Jul 28, 2009 (gmt 0)

The easiest way I can think of is to use a VBscript Class to contain the 4 values, and just store the class in the dictionary.

Class Statement (VBScript) [msdn.microsoft.com]

abidshahzad4u




msg:3961033
 2:03 pm on Jul 28, 2009 (gmt 0)

Thanks.

Can you explain this little?

Ocean10000




msg:3961097
 4:09 pm on Jul 28, 2009 (gmt 0)

<sample>
Class Customer
Private m_CustomerName
Private m_OrderCount

Private Sub Class_Initialize
m_CustomerName = ""
m_OrderCount = 0
End Sub

' CustomerName property.
Public Property Get CustomerName
CustomerName = m_CustomerName
End Property

Public Property Let CustomerName(custname)
m_CustomerName = custname
End Property

' OrderCount property (read only).
Public Property Get OrderCount
OrderCount = m_OrderCount
End Property

' Methods.
Public Sub IncreaseOrders(valuetoincrease)
m_OrderCount = m_OrderCount + valuetoincrease
End Sub
End Class

Dim c
Set c = New Customer
c.CustomerName = "Fabrikam, Inc."

c.IncreaseOrders(5)
c.IncreaseOrders(3)

Set objDict=CreateObject("Scripting.Dictionary")
'default comparison is binary mode with is CaSe SenSiTive

'You can only change the CompareMode property while the Dictionary object has no keys

objDict.CompareMode=vbTextCompare

objDict.Add "KEY",c

dim samevalue
set samevalue = objDict.Item("KEY")

response.write samevalue.CustomerName
response.write " should be 'Fabrikam, Inc.'"
</sample>

abidshahzad4u




msg:3961539
 6:52 am on Jul 29, 2009 (gmt 0)

Thanks. Your Idea help me a lot. I am stuck again. I have implemented the same idea, created class with 5 properties. When adding item to the shopping cart, I have added properties to the class object and added to the objDict.

Now how can I access the object in the objDict through for each loop or some other solution.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved