Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shopping cart query

Status
Not open for further replies.

janise

Technical User
May 25, 2003
161
US
I have been working on a shopping cart program for awhile and finally have gotten all the coding done.
There is one quick question that I have,
how do you integrate the administrative stuff with the rest of the shopping cart program?
For instance, the administrative backend processing involves adding new categories to the store, adding new products, removing and updating products.
To get the the administrtative pages, a login is needed and has been created but I was wondering if the administrative page is going to be part of the shopping cart program in that you add a link called administrion with login credentials.
Please shed some light on this for me.
Thanking you in advance.
 
janise,

That can be done in a variety of methods. For instance I have a site that using the shopping cart and wishlist. We handle the security first by forcing everyone to log in before they can even look at the catalog. Then we give each customer basically an administrative account to handle logins for both their employees or people they want to see the site. Now our products are constantly changing and permission being given to customers on a need basis so instead of dealing with coding permissions to allow this customer to see this and that I went ahead and set up a folder for each customer and a global folder for all customers. Then I give them a windows to setup permissions on those folders. When we update their catalog with a new part we just add it to their folder. This way the admin doesn't have to worry about getting phone calls for each account.

Down side of my method is the upfront administrative tasks. It also means that a restricted product from the public but allowed to certain customers will have duplicates.

What I always do is make a list of somekind illustrating what would be your ideal solution for security. Then take your currecnt site and try to map a flow chart to list you created. You can get more indepth on this if you want but usually I get tired of the paperwork from here and jump into the code.

If you need some sample code or help with implementing something let me know. I will post what I have already and try help as much as I can on what I don't have.

Hope this helped.

Cassidy
 
Cassidy, thank you very much.
First, I appreciate the offer for some sample code.
The only sample code I would need, if you care to disperse of some are the wishlist code, and if possible, the specials code.
I have coded the weekly specials code as far as the insert into the database.
I have also done a lot of work on that as far as displaying weekly specials.
However, the customer has said both wishlists and specials are not urgent right now but will be needed.
So a sample code will help reduce the work.
As far as the administrative stuff is concerned, the customer wants to handle of all of that herself.
She wants to be to add products or categories, delete and or update products and categories.
She doesn't want the customers doing so.
As indicated, I have already coded these administrative functions.
I am just wondering how to integrate them with the rest of the shopping cart program.
I have seen some samples where the administrative page is part of the menu but I worry about security implications.
Then again, I can't think of any other way to handle this part.
Right now, I just have something similar to:
Home | Contact Us | About Us | Products | Terms & Conditions | Administrative page.

This is my current setup but even though the administrative page has login info, I still worry about security and hence the professional advice.
 
Let me get a public version of my wishlist and special page put together. Might take me a day or so. As for the administrative page what would be the problem with adding another A record to the domain? could be something like admin.thisdomain.com .

That would keep it off the main page completely, give the customer a way to distinguish between the ecommerce site and maintenance site. As far as security goes 99% of it is if you don't see it, it isn't there.

Now what portion most interest you about the wishlist? My focus on the wishlist and shopping cart is to keep a two way communication line between the business and thier customers. I would do this by keeping track of information such as searches, shopping cart, navigation, and of course the wishlist. Then I would make sure the business had access to this information. My next step which is not complete is to build the site to market to the customers needs, make the searches taylor to successful and similiar results, etc...

If it were me I try to keep things as simple as possible. Your worried about security so place that out of site in an A record. Integration into the shopping cart I would handle in a disconnected recordset and update it at the point of sale. It really vary's to when that time should be. Then I would look into the checkout feature of the shopping cart and offer an https site to complete the transaction.

I hope this helps and I will get you some sample code soon.

Cassidy
 
hi Cassidy,
I was wondering if you forgot to give me the sample codes you promised.
Thanks very much
 
Janise,

I apologize for the delay. I went out of town and got caught up in a project. Here is the code I promised. This contains functions associate with what we discussed.

For the sake of speed and the ability to use my companies database I had to make some COM components. However the functionality of the code is still there and should point you in the right direction.

Please feel free to ask me anything. If you do not understand a compiled function let me know and I will detail out the compiled part here.

I apologize for the delay again and will do better in the future.

Cassidy

-----------------------------------

Function Wishlist_Initialize()
'Is the B2C Module being loaded, if yes then load a wishlist based on whether the cookie has a valid wishlist ID
'and whether the wishlist has a customer id on it or not.
If Not Session("B2BModule") Then
'Since Cart_Initialize was called already, assume that the Wishlist ID has been loaded.
If Not IsBlank(Session("sWishlistID")) Then
'Is the User Logged in. If Not then simply check the current cart and then load a corresponding cart
If Not LoggedIn() Then
If Wishlist_HasOwner(Session("sWishlistID")) Then
Session("sWishlistID") = ""
End If
Call Wishlist_Load()
Else
'If the user is logged in then get the correct wishlist for this customer and merge the existing wishlist.
Session("sWishlistID") = Wishlist_MergeWishlists(Session("sWishlistID"))
Call Wishlist_Load()
End If
'First time user,load a blank cart and then save the cookie to the user's machine.
Else
Call Wishlist_Load()
End If
Else
'If logged in then load the default wishlist
If LoggedIn() Then
sWishListID = Wishlist_GetDefaultCustomerWishlist(Session("sCustomerID"),Session("nContactNO"))
If IsBlank(sWishListID) Then
Session("sWishListID") = ""
Else
Session("sWishListID") = sWishListID
End If
Wishlist_Load()
End If
End If
'Write the cookie back with the correct Wishlist ID.
SaveCookie()
End Function

'************************************************************************
' Wishlist_GetDefaultCustomerWishlist()
' This function grabs from the database a wishlist id for a given Customer ID and contact Number
Function Wishlist_GetDefaultCustomerWishlist(sCustID,nContactNo)
Dim WSObj, Rs,sWishlistID,sSql
If Session("PrimaryUser") Then
sSql = "Select * from WISHLIST where CUSTOMER_ID = '"& sCustID & "' and CONTACT_NO is null and NAME = 'PRIMARY_WISHLIST'"
Else
sSql = "Select * from WISHLIST where CUSTOMER_ID = '"& sCustID & "' and CONTACT_NO = '" & nContactNo & "' and NAME = 'PRIMARY_WISHLIST'"
End If
sWishlistID = null
Set WSObj = Server.CreateObject("VwebSls.Sales")
Set Rs = WSObj.Query(Session("VWEB"),sSql)
If Not Rs.EOF Then
sWishlistID = Rs("ID")
End If
Set WSObj = Nothing
Set Rs = Nothing
Wishlist_GetDefaultCustomerWishlist = sWishlistID
End Function


'************************************************************************
' Wishlist_Load()
' Loads a Wishlist for a given session via the session("sWishlistID") variable, if this variable is empty
' then it loads a brand new Wishlist. If the Session variable has a value and the Wishlist can not be found
' then it loads a new Wishlist too.
Function Wishlist_Load()
Dim WishlistObj, Rs
Set WishlistObj = Server.CreateObject("VwebSls.Wishlist")

'Check to see whether a Wishlist exists in the Session variable first
If Not IsBlank(Session("sWishlistID")) Then
Set Rs = WishlistObj.Load(Session("VWEB"), Session("sWishlistID"))
If Rs.EOF Then
'Wishlist exists but is not found in the database, load a brand new one and save its id to the session variable.
Rs.AddNew()
Rs("NAME") = "PRIMARY_WISHLIST"
Rs("CUSTOMER_ID") = Session("sCustomerID")
Rs("CONTACT_NO") = Session("nContactNO")
Rs.Update()
Set Rs = WishlistObj.Save(Session("VWEB"),Rs)
Session("sWishlistID") = Rs("ID")
End If
Else
Set Rs = WishlistObj.Load(Session("VWEB"),"")
If Rs.EOF Then
Rs.AddNew()
Rs("NAME") = "PRIMARY_WISHLIST"
Rs("CUSTOMER_ID") = Session("sCustomerID")
Rs("CONTACT_NO") = Session("nContactNO")
Rs.Update()
Set Rs = WishlistObj.Save(Session("VWEB"),Rs)
Session("sWishlistID") = Rs("ID")
End If
End If
Set WishlistObj = Nothing
Set Rs = Nothing
End Function


'************************************************************************
' Wishlist_Add()
' Add a part qty to the current Wishlist
Function Wishlist_Add(sPartID,sComments)
Dim Wishlist
Dim Rs, Rs2
' Get the shopping cart from session memory
Set Wishlist = Server.CreateObject("VwebSls.Wishlist")
If sComments = Null Then
Set Rs = Wishlist.Load(Session("VWEB"), Session("sWishlistID"))
Else
Set Rs = Wishlist.Load(Session("VWEB"), Session("sWishlistID"),"WITH_TEXT_DATA")
End If
' Add the parts to the Wishlist
If Not Rs.EOF Then
Set Rs2 = Rs("WISHLIST_LINE").Value
Rs2.Filter = "PART_ID = '" & sPartID & "'"
'If Part does not exist in the wishlist then add it else change the comments
If Rs2.EOF Then
Rs2.AddNew()
Rs2("PART_ID") = sPartID
If Not IsBlank(sComments) Then Rs2("COMMENTS_DATA") = sComments
Else
If Not IsBlank(sComments) Then Rs2("COMMENTS_DATA") = sComments
End If
Rs2.Update
Rs.Update
Set Rs = Wishlist.Save(Session("VWEB"), Rs)
End If
Set Wishlist = Nothing
Set Rs = Nothing
End Function


'************************************************************************
' Wishlist_HasOwner()
' This function will determine whether a wishlist which has been loaded has a Customer ID on it.
Function Wishlist_HasOwner(sWishlistID)
Dim Rs,WishlistObj, bExists
bExists = False
Set WishlistObj = Server.CreateObject("VwebSls.Wishlist")
Set Rs = WishlistObj.Load(Session("VWEB"), sWishlistID)
If Not Rs.EOF Then
If Not IsBlank(Rs("CUSTOMER_ID").value) Then
bExists = True
End If
End If
Set Rs = Nothing
Set WishlistObj = Nothing
Wishlist_HasOwner = bExists
End Function

'************************************************************************
' Wishlist_MergeWishlists(sCurrentWishlistID)
'This function is used when the user has logged in(under the B2C style website) and you merge the current wishlist with
'the default wishlist used by this customer
Function Wishlist_MergeWishlists(sCurrentWishlistID)
'The current wishlist does not belong to anyone. However the user might either have a wishlist in the system
'or you might have to create a wishlist.
'First check whether the user has a default wishlist.
Dim WishObj, RsWish,RsWishlist
Set WishObj = Server.CreateObject("VwebSls.Wishlist")

sDefaultWishlistID = Wishlist_GetDefaultCustomerWishlist(Session("sCustomerID"),Session("nContactNO"))
If Not IsBlank(sDefaultWishlistID) Then
Set RsWish = WishObj.Prepare(Session("VWEB"),"MERGE_WISHLISTS")
If RsWish.EOF Then
RsWish.AddNew()
RsWish("FROM_ID") = sCurrentWishlistID
RsWish("TO_ID") = sDefaultWishlistID
RsWish.Update
Set RsWish = WishObj.Save(Session("VWEB"),RsWish)
Wishlist_MergeWishlists = RsWish("TO_ID")
End If
'Customer does not have a default Wishlist, make the current one his since it does not belong to anyone.
Else
Set RsWishlist = WishObj.Load(Session("VWEB"),sCurrentWishlistID)
If Not RsWishlist.EOF Then
RsWishlist("NAME") = "PRIMARY_WISHLIST"
RsWishlist("CUSTOMER_ID") = Session("sCustomerID")
RsWishlist("CONTACT_NO") = Session("nContactNO")
RsWishlist.Update
Set RsWishlist = WishObj.Save(Session("VWEB"),RsWishlist)
End If
'Return the same Wishlist ID as the default Wishlist for this customer.
Wishlist_MergeWishlists = sCurrentWishlistID
End If
Set WishObj = Nothing
Set RsWish = Nothing
Set RsWishlist = Nothing
'Delete the wishlist which was just merged if there are no user's associated with it.
'If Not Wishlist_HasOwner(sCurrentWishlistID) Then
' Wishlist_DeleteWishlist(sCurrentWishlistID)
'End If
End Function

'************************************************************************
'Wishlist_DeleteWishlist(sCurrentWishlistID)
'This function deletes a wishlist from the system.
Function Wishlist_DeleteWishlist(sWishlistID)
Dim WishlistObj, Rs
Set WishlistObj = Server.CreateObject("VwebSls.Wishlist")
Set Rs = WishlistObj.Load(Session("VWEB"),sWishlistID)
If Not Rs.EOF Then
Rs("RECORD_IDENTITY") = "DELETE"
Rs.Update()
Set Rs = WishlistObj.Save(Session("VWEB"),Rs)
End If
Set WishlistObj = Nothing
Set Rs = Nothing
End Function

'************************************************************************
'Wishlist_DeleteItem(sPartID)
'This function deletes items from the wishlist
Function Wishlist_DeleteItem(sPartID)
Dim Obj, Rs,RsLine
Set Obj = Server.CreateObject("VwebSls.Wishlist")
Set Rs = Obj.Load(Session("VWEB"),Session("sWishlistID"))
If Not Rs.EOF Then
Set RsLine = Rs("WISHLIST_LINE").value
RsLine.Filter = "PART_ID = '"& sPartID & "'"
If Not RsLine.EOF Then
RsLine("RECORD_IDENTITY") = "DELETE"
RsLine.Update()
End If
Rs.Update()
Set Rs = Obj.Save(Session("VWEB"),Rs)
End If
Set Obj = Nothing
Set Rs = Nothing
Set RsLine = Nothing
End Function

'************************************************************************
'ValidWishlistName(sWishlistName)
'This function determines that the wishlist name being given does not already exist in the system
'for a given customer and contact no
Function ValidWishlistName(sWishlistName)
Dim QueryObj2,bSuccess, Rs,sSql
bSuccess = False
If Session("PrimaryUser") Then
sSql = "select * from WISHLIST where NAME = '" & sWishlistName & "' and CUSTOMER_ID = '" & Session("sCustomerID") & "' and CONTACT_NO is null "
Else
sSql = "select * from WISHLIST where NAME = '" & sWishlistName & "' and CUSTOMER_ID = '" & Session("sCustomerID") & "' and CONTACT_NO = " & Session("nContactNO")
End If
Set QueryObj2 = Server.CreateObject("VwebSls.Sales")
Set Rs = QueryObj2.Query(Session("VWEB"),sSql)
If Rs.EOF Then
bSuccess = True
End If
Set QueryObj2 = Nothing
Set Rs = Nothing
ValidWishlistName = bSuccess
End Function

'************************************************************************
'Create_NewWishlist(sWishlistName)
'Creates a new wishlist for a given customer and contact number and then resets the Current Wishlist being loaded to the new one.
Function Create_NewWishlist(sWishlistName)
Dim WishlistObj2, RsWishlist
Set WishlistObj2 = Server.CreateObject("VwebSls.Wishlist")
Set RsWishlist = WishlistObj2.Load(Session("VWEB"),"")
If RsWishlist.EOF Then
RsWishlist.AddNew()
RsWishlist("NAME") = sWishlistName
RsWishlist("CUSTOMER_ID") = Session("sCustomerID")
RsWishlist("CONTACT_NO") = Session("nContactNO")
RsWishlist.Update()
Set RsWishlist = WishlistObj2.Save(Session("VWEB"),RsWishlist)
Session("sWishlistID") = RsWishlist("ID")
End If
Set WishlistObj2 = Nothing
Set RsWishlist = Nothing
End Function


%>

---------------------------
 
Thank you so very much, Cassidy!
This is truly appreciated.
Let me play around with it.
If I get stuck, I will come calling on you.
Again, many, many thanks.
 
No problem. Normally i am better at getting the code out there. I really just dropped the ball and got distracted. I am sorry.

I hope it helps.

Cassidy
 
No need to apologize.
Your integrity is intact with me.
 
hi Cassidy,
I hope you are still a member of this forum.

I have been looking for a "wishList" code.
Fortunately, I searched through the forum and found this.

I was wondering if you could be kind enough to explain to me how to use this code.

I am not really that familiar with functions.

Hope to hear from you.
Many thanks in advance
 
To use the code you need to have a database that contains your wishlist records. You also need to initialize the wishlist with a cookie. That can be done using the Wishlist_Initialize function and be part of the process of logging into the site. I am sure there are other ways to use it. That is how I handle it. For the most part from here I just call functions as I need them based on the users interaction. Add, delete, load, merge and so on. I tried to comment the code well.

Do you have a specific question or objective you are trying to use this code for? Some of the code requires some compiled com components that I created for the sake of speed and simplicity.

Let me know what I can do.

Cassidy
 
Many, many thanks for the response.

I am not really that familiar with functions.

I guess my biggest issue is that I can't run the code because they are functions.
When I do, of course they are blank.

As silly as this question might sound to you, if for instance I need a customer to add to his wish list, is there a sample code that can show me how to call that function in asp?

I suppose that sample code will guide on how to call the rest of the functions.
 
That is a tough one for me. The sample code was edited snapshot of the whole code for security. Let me see if this makes since.

Code:
<%
Response.Write example("Called this function<BR>")
'or you can do it like this

dim sResponse

sResponse = example("Another Called function<BR>")
Response.Write sResponse

'or yet another possibility

dim sVar

sVar = "Information I am going to pass to another called function<BR>"
sResponse = example(sVar)
Response.Write sResponse

function example(argument)
	example = "This is the item passed " & argument
end function
%>

On some functions that you do not expect to return a value but simply perform their task you can use

Code:
call example ("Variable Here")

As far as adding a user to a database so that you can form the wishlist ID's and such that is really something that needs to be thought out for your needs. Here is an example of adding a record to a database using a function.

Code:
'Recieved user information to add from a form calling function

Call AddUser(Request.Form("txtUserName"),Request.Form("txtUserFirstName"),Request.Form("txtUserLastName"),Request.Form("txtUserPassword"))

'User has been added continue to another page
Response.Redirect "someplace.asp"

function AddUser(sUserName,sUserFirstName,sUserLastName,sUserPassword)

dim cn
dim rs

Set cn = Server.Createobject("ADODB.Connection")
Set rs = Server.Createobject("ADODB.Recordset")

With cn
    .provider = "Microsoft.Jet.OLEDB.4.0" 'Replace with your provider
    .Connectionstring = "c:\database.mdb"
    .open
end with

rs.open "Select * from table",cn,3,3

rs.addnew
    rs("UserName") = sUserName
    rs("UserFirstName") = sUserFirstName
    rs("UserLastName") = sUserLastName
    rs("UserPassword") = sUserPassword
rs.update

'Clean up database connections
set cn = nothing 
set rs = nothing

end function

I didn't test all the functions but I think this should give you a flavor of what you are looking for.

Let me know if you need more help.

Cassidy
 
Cassidy,
Thanks again for your response.

I have been playing around with the sample code you posted = the one with call Adduser(...)

Two questions come to mind.
1, I can see where the call Adduser comes from but where did those request.form variables come from?

Does it mean that I have to create a form and create those form variables and then post to this page?

Second, I am also struggling to see the connection between the functions you posted and the sample code.

I was expecting see where any of those functions, especially when adding new wishlist to the db like wish_listAdd, etc

I told you I am not good when it comes to using and calling functions - obviously, I need to get better with those and will.
 
First question. Yes you need to create a form and post it to this page to add users. No you do not create variables with those names. You need to name the text boxes on the form those names. You can name them anything you want but you have to make sure they are the same in both places.

Second question. Where the wishlist functions would come in would be as the user logs in. You would need to have the user create a username, password and wishlist ID. So when the user logs in you can validate the login and then call the Wishlist_Initialize() function. You would call the functions just as I did in the examples. Then you would have another page that would serve as your catalog page and so on where people could click to add or delete items from the wishlist. When that happens you would call the Wishlist_Add(sPartID,sComments) function and pass it the PartID and Comments field attached to that item.

To clarify what you see above is just the functions involved in teh wishlist. It is not the complete site. Also anyplace you see VwebSls.Sales or something of that nature is a compiled com component that I wrote in Visual basic for speed and security.

The steps to do the above successfully are:

1. Create a database
- User table that has names and passwords
3. Catalog table that holds all your poduct informtion
- Picture locations, descriptions etc..
2. Wishlist table that can point to a document (Possibly XML) that would house the wishlist items
3. Site navigation
- login page, catalog page, session handling pages etc...

Granted the above steps are really brief but all those things need to be in place to make the above code work. Let me see if I can put together a sample that calls that code.

Hopefully this helps a little.

 
Yea, what is "bugging" me so far is the dlls you used in the code.

Let me ask you an alternate question.

I am so desparate that I willing to pay for it even though it is not my personal business.

The question is whether you have samples of order tracking or order status.

I have presented to management the difficulty of making that wishlist work.

They suggested that if we can come up with order tracking or "My Account" functionality, they can let go of the wish list.

Do you have samples of any of those?

I am having a huge difficulty making the code you graciously made available to this forum.
 
Sure. My E-business site I create for lnh.net is complete with wishlist and order tracking.

Having the wishlist, order tracking, and everything that your wanting is not very difficult to do. You just need to get some preparation.

First what type of database do you have that currently tracks your customers?

Next what type of security do you need with your customers?
-- Are you going to take credit cards?
-- Are you handling any personal data?
-- Is the information in the database highly propriatary?

Do you have a database map?
-- How orders and such are processed and what fields you will need to be able to show?

After you have the basic information like that it is easy to design the page and make the functionality work. I imagine your going to have the following:

Tables:

Customer
Customer_Order
Customer_Order_Line
Part
Inventory_Transaction
Requirements
Work_Order
Shipper
Shipper_Line
Invoice
Invoice_Line

This is how my database works. Customers information is entered into the Customer table. When an order is placed the ID in the customer table is placed in a field in the customer Order table. Each line of the Customers order is place in the Customer_Order_Line table. The items the customer is ordering have to come from the Part table. Each part has to be adjusted out of Inventory in the Inventory transaction table. THat is also where I pull my costs. When the work order is created each part may have requirements of sub parts or assemblys. That is placed in the requirements table. Finally the item is ready to ship and a shipper is created. This also creates and invoice with final customer price and shipping information. Those are placed in the shipper, shipper_line, invoice, invoice line table.

I work with an Oracle Database. This is a pretty quick description of what happens but it is similiar to what you or anyone else would need to know to build what your wanting. The wishlist is just another table with the customer id tied to it. Our data is highly propriatary so that is why I handle my secured transactions in a COM component.

Let me know what you need and I will see what I can come up wtih. Also let me know some of the information on a database and we will see what we can do.

Cassidy

 
Cassidy
I have all kinds of work I need to get done here too. can you do it for me. [lol]

kidding...

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
Well, we shouldn't discourage someone who is trying to help.

All I really wanted was samples on how to do order tracking.

Cassidy,
I have already designed my database and the datatabase that handles order tracking is called just that - ordertracking with custid joining it with customer table.

I just want to take step by step.
I have got the basic shopping cart working with security built into it.
I have implemented "My Account" page with a page called orderstatus.asp.

Infact I just posted that page here because I have just been asked to implement a search functionality so that a customer would have the option of scrolling/paging or searching for a specific order.

The only that I am trying to work out there now is the error handling bit.

So, I am making progress.
And as I progress with this ecommerce, I will be asking experts like you guys for help in some areas that I might be struggling with.
Right now, that area is the order tracking bit.
If I get that implemented, we will be ready to deploy it.
Improvements will be added as needed.

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top