Current location: Hot Scripts Forums » Programming Languages » PHP » I need another advice: Shopping Cart


I need another advice: Shopping Cart

Reply
  #1 (permalink)  
Old 12-07-05, 12:53 AM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
I need another advice: Shopping Cart

Ok I learned that if you want to make a shopping cart, you should generate a session ID for that user that comes to your shopping cart. When he/she adds a product to the shopping cart, then store that session ID in a cookie then store that cookie on there computer, while the added products will be stored in the database with there session ID stored as well so when the user even turns off there computer, come back and there products are still stored in there shopping cart which is awesome. My question is how can I make it so if the user decides not to come back in like a month time, then delete there products off the database?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-07-05, 05:06 AM
php~pro php~pro is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: In a nice house.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Set up a crontab to purge all records that have been inactive for over 1 month or make a web based admin form to do this for you. Just create a recursive loop that runs until all files older than 1 month are deleted.

Search google for tutorials on Crontab or cron job. You may find 1 on phpfreaks.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-07-05, 11:18 AM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
Is there a way that I can use the date function where if it is pass 31 days then I can excute whatever command I want.

PHP Code:

<?php

$currentdate 
date("y d m");
$olddate "05 06 12";

$total $currentdate $olddate;
?>
the answer is 100 therefore the answer is wrong, the answer is suppose to be 1.
Can anyone guide me with some helpful suggestions. I dont really want to get into cron jobs.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-07-05, 04:39 PM
ben.periton ben.periton is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
What I have done in the past, is as part of the function to check if they already have a shopping cart or not, is to delete any shopping carts that are over 2 days old.

Using the time() function and a bit of maths, you can easily do it. Just make sure you store the times as the unixtimestamp.

PHP Code:

$delTime '172800'// 2 days ((60*60*24)*2)

$query "DELETE * FROM shoppingCarts WHERE CreatedTime <".(time()-$delTime); 
__________________
Ben Periton
http://ben.periton.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-07-05, 10:31 PM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by XTech
PHP Code:

$delTime '172800'// 2 days ((60*60*24)*2) 

Hey thats cool. How did you get ((60*60*24)*2) ? What does each represent (eg: 60 = seconds, 60 = mins, 24 = hours, 2 = days) ?

please reply back
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-08-05, 08:31 AM
ben.periton ben.periton is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Checkout http://uk.php.net/time theres a lot of useful stuff there.
Yup, 60 seconds * 60 minutes * 24 hours gives you the number of seconds in day, which is what time() is based on.
__________________
Ben Periton
http://ben.periton.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Sessions for a shopping cart mcrob PHP 8 12-03-05 07:11 PM
shopping cart project d2daj Script Requests 2 11-20-05 12:43 AM
Custom Shopping Cart ($$$$) SpidersandWebs Job Offers & Assistance 5 11-16-05 12:54 AM
shopping cart cutomization limits?? vega PHP 1 06-11-04 12:26 PM
OO Shopping Cart Serialization wheezy360 PHP 1 12-29-03 09:09 PM


All times are GMT -5. The time now is 08:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.