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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't wrap my head around this array/string problem...

Status
Not open for further replies.

andrewEmbassy

Programmer
Aug 2, 2005
15
US
Okay, so here's my issue. I'm working on a shopping cart and we've got it set up so the users cart is a cookie kept on their machine, with they key names being the itemId's and the values being the number of each they've purchased.

I'm writing the receipt page that'll have "thank you! your order went through fine, here's what you've purchased... etc."

Now, we're using a third party credit card verification system, and the receipt page is hosted on their server so the cookie from our domain won't work. Also, there's very limited variables we can pass to the third party server about the purchase- aside from the amount and billing/shipping info, there's not much else the server will take.

It seems like we've got two options (without throwing the whole cart system out the window and creating carts on the database, something that I'm still contemplating).

One: I can figure out how to set multiple domains on the cookie. I've been told this is kind of a difficult thing to do and that I may run into browser issues along with security issues. Is there any way I can write a cookie so it can be read by multiple domains?

two: I can take my cart, convert it into a string, post that string in the x_description variable they give me, and then when it's echoed to the receipt page compile that string into an array and use it to populate the info.

This option seems like it would be the simplest, but while I could use split() to make a one dimensional array, I need to use it to make a multi-dimensional array. Ideas? I can write the string fine, right now I've got it something like this:

SM150=>1,SM344=>3,SM250A=>2 Where SM150 is the key and 1 is the value.

How do I get that into a multi-dimensional array?

Thanks in advance...
 
Have a look at the Split, UBound, Left, Mid and InStr functions and at the ReDim instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Most third party CC systems have a round-robin sort of approach where you post to them some fields, and they send some stuff back.

Usually, the only thing(s) you need to send to the CC company is a charge total, and maybe an order_id...

I'd suggest setting up an "order" table some how (if you have a database, it would be best to store it here) that would store things like how many of what was ordered, and by who)

Save that off before you submit your total amount to the CC processing company.

Pass your values, and see if you can get the order_id back from the CC processing company.

The cc processing company should send back the order_id along with a sort of pass/fail response as to weather or not they actually paid for the product.

Record any information required to your orders table and close out your cookies afterwards...

ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
Hey folks-

Thanks for the info- yeah, wholesea that's kind of what I'm tempted to do- just create a new table for each user... but I'm afraid that'll be too huge a project and will push the launch farther back...
 
Don't need a new table for each user, just an order table...

tbl_Orders
-------------
order_id -- Auto Number field
First_name
Last_name
address1
adderss2
city
state
zip
dtm_order_date -- Date the order was placed
dtm_order_complete_date -- Date the order was paid for
dtm_order_fufilled -- Date the order was shipped

tbl_order_items
---------------
order_id -- Link to the orders table
product_id -- Link to your product id in your product table
quantity -- number of items sold

Then, before you forward the users over to the CC Process take your cart items and dump them into the tables...

sql="select * from tbl_orders where 1<>1"
rs.open sql, conn, 1, 3
rs("first_name") = request("first_name")
rs("last_name") = requesT("last_name")
rs("address1") = request("address1")
rs("address2") = request("address2")
rs("city") = request("city")
rs("State") = request("state")
rs("zip") = request("zip")
rs.update
order_id = rs("order_id")
rs.close

for each item in request.cookies("cart")
sql = "insert into tbl_order_items (order_id, item_id, quantity)(" & order_id & "," & [find the item id in the cart array] & "," & [find the count in the cart array] & ")"
conn.execute(sql)
next

Then forward them over to the CC Collection system...


ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top