Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Tips for shopping cart?!
Old 12-20-2007, 03:37 PM Tips for shopping cart?!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
hey, okay im tryin to have a go at making a simple shoping cart.

i have already set up my DB table for products and i have got my page to show them with pagination.

Now im at the stage of creating my add to basket script bit so i can then get the info for ordering and displaying basket contents.

Now im thinking to use cookies, and was going to have

setcookie(product_id, 1, mktime() + 3 days)

but twigged that it will over write the older one

so what would be the best way to do this?

Thanks,
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 12-20-2007, 04:39 PM Re: Tips for shopping cart?!
Junior Talker

Posts: 3
Name: Joe
Trades: 0
Hi Dan.

You could create cookies using an incrementer in the name of the cookie.

ex: productID0, productID1, etc..

then with php variables inside variables { } loop thru
$_COOKIE['productID{$incrementer}'] from 0 to whatever cookie is set.

or use an array

jd.
mrSnacks is offline
Reply With Quote
View Public Profile
 
Old 12-20-2007, 05:52 PM Re: Tips for shopping cart?!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
im thinking more having a database and have a cookie with the identifier
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-20-2007, 06:32 PM Re: Tips for shopping cart?!
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Session Cookies would be the best way to do this, it's like a cookie that only lasts for the visit (Until browser is closed/emptied). The Values are stored server side in a flat file (making them load up faster in an array!).

I find them much more simple to use then cookies (What need to be set before headers sent).

http://uk.php.net/manual/en/ref.session.php
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 12-20-2007, 07:25 PM Re: Tips for shopping cart?!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Yeah - you could create a database row in a shopping_cart table with a master id and serialized data for the products stored. Saving a cookie on the users end with the shopping_cart id for retrieval. If a session is new and the shopping_cart cookie is set, you can pass the shopping cart data in a session varible. Whenever the user modifies contents in thier cart, you can overwrite the serialized data in the db table.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 12-21-2007, 02:24 PM Re: Tips for shopping cart?!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
okay i have got my "basket" bit done now i think,
i have a databse table with
basket_id | sid | product_id | product_qty | add_time

and it inserts everytime something is added to users basket, ALSO i have it to if they add to basket on a item which is already in their basket instead of adding another record it adds the saved qty to the new qty to be added.

i think at the moment i have to get my basket page done to show basket contents and have delete etc options.

and my order script.

BUT at the moment the only form of payment is check in the post, but i am hoping to be able to get permission for online donation, and can then have it forward them to the donation service with the total amount all done so they just enter card details and "donate" and then once its confirmed ship order.

but i need it so its flexibile just not sure on best way to go about it.

Thanks!
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Tips for shopping cart?!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23704 seconds with 12 queries