Welcome to WebmasterWorld Guest from 54.196.244.206

Forum Moderators: ocean10000

Message Too Old, No Replies

Classic ASP shopping cart help

Classic ASP shopping cart help

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

Junior Member

5+ Year Member

joined:May 11, 2009
posts:74
votes: 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?

1:50 pm on July 28, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:852
votes: 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]

2:03 pm on July 28, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:May 11, 2009
posts:74
votes: 0


Thanks.

Can you explain this little?

4:09 pm on July 28, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:852
votes: 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>

6:52 am on July 29, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:May 11, 2009
posts:74
votes: 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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members