Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Shopping Cart Product Button to View Cart

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Shopping Cart Product Button to View Cart

Postby NYColt » Mon Apr 21, 2003 10:47 am

I was wondering if some patient someone here might be able to help with something before I pull my hair out. I have downloaded some of the open souce carts out there and tinkered with them but all of the ones I have found in php are more elaborate then I need.

I would like to know what the easiest/quickest way to create a simple shopping cart that will allow me to click an item button that contains all of my product info: itemid, customerid etc. that opens a view cart page that can have additional items added to it and removed (continue shopping or remove item). I would like from the same cart page be able to select shipping option and have shipping and items calculated on that page to a grand total amount. Then on click checkout send the informtion via: "method:get" to the credit card proccessor. Basiically what I want to do is what is done for most Pay Pal sites except I want to send the info to a different proccessor.

The specific problem I am having trouble figuring out (for about 72 hours and counting) is how to keep items in the cart when the customer goes to make more selections. I realize I need a session_start() function on all the pages which I have done but whenever I return to the "cart" page it has removed the previous selection and added the new one.

Any help with this would be soooooooooooo greatly appreciated.
You guys here are aloways a great help to me.

Thanks
NYColt
NYColt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Fri Feb 14, 2003 2:33 am
Location: New York

Postby Skeletor » Mon Apr 21, 2003 11:26 am

Is your items getting added to an item array? If one item is overwriting the previous item, perhaps the variable isn't adding to an array, but overwriting the value. I'm not sure if this is what it is without seeing your code, but if you have something like:
$_SESSION['items'] = "the new item id";

you might want to switch it to this:
$_SESSION['items'][] = "the new item id";
- This would make $_SESSION['items'] an array and add the new id to that array every time.

If this is of no help, perhaps post an example of your code for the people to take a look.

Good luck.
Skeletor
New php-forum User
New php-forum User
 
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

I'll start there..

Postby NYColt » Mon Apr 21, 2003 11:42 am

That is a start!

I was not really sure how to get it started to be honest with you. let me try doing that. I will try sending the selected items to an array. That makes sense now. Thanks!
I will post back here if I get stuck further along.
That is the best approach you think? send to an array on the cart page?

NYColt
NYColt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Fri Feb 14, 2003 2:33 am
Location: New York

Postby Skeletor » Tue Apr 22, 2003 4:42 am

I actually just started playing around with creating a cart script, so I'm not sure what the best way to go is. I found that using an array worked well with allowing the user to add and delete entries from his/her cart. One thing you might want to consider is if you want the cart to empty when they close their browser? If you want their cart to remain populated, it might be best to write the cart to a database instead of just an array.

Sorry for not being a bit more help. I just started toying around with creating a shopping cart script, so I haven't had a chance to play and see what works best.

Good luck.
Skeletor
New php-forum User
New php-forum User
 
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

Postby NYColt » Tue Apr 22, 2003 5:22 am

Yeah, I think thats what I am going to do. When they click submit on the cart, which will send the info to the proccessor I will have the info save to the database at that time.

Im messin around with the $_session and add to and delete array thing now. Im pretty new to PHP and kind a hacken around, just want to try and get off on the right foot with this cart, don't want to be knees deep from the get go...
NYColt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Fri Feb 14, 2003 2:33 am
Location: New York


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.