gc40 Posted August 27, 2007 Share Posted August 27, 2007 Greetings All, I am looking at creating an extremely simple shopping cart. I have already made the script that would allow me to add categories and products, along with displaying those categories and products. The script also allows me to edit/delete and add new categories and products. However, I would like visitors to be able to view products then add them to a virtual shopping cart. Once the product is stored in the shopping cart, he can then click checkout. My checkout is going to be a bit different. I do not allows users to sign in or register because we are only offering 10-20 products, however, when they add products to the shopping cart, it will be stored based on sessions that are logged by cookies. Now, when they click submit, it will ask them for their EMAIL, FULL NAME, TELEPHONE, and ADDRESS. Once they fill it in and submit, the products they choose and their information will be emailed as a purchase order to my email inbox. Can anyone guide me to a script that does this or help me make one? I am lost and need some urgent help. Thanks. Quote Link to comment Share on other sites More sharing options...
chronister Posted August 27, 2007 Share Posted August 27, 2007 Here is a mail script. You will have to customize it to what your needs are though. <?php $headers ="MIME-Version: 1.0" . "\r\n"; $headers .= "X-Mailer: PHP/" .phpversion() ."\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: NAMEHERE <user@domain.com>"; //set your from address here $to=$email;//set the email address it being sent to $subject = 'Subject '; //subject of email $body=' Body of Email Here'; //the body of the email mail($to, $subject, $body, $headers); ?> This is the basic code. Generally for the body part, I will make a new html doc and make it a nice layout there plugging in the variables that are going to be used in the script. Then once I have the layout and everything looks good in that html doc, I then copy and paste the table's code from there into the body var in this mail script. Make sure you concatenate all the vars in the $body. As far as gathering the product info for this mail script you will need to do a few queries to grab the info you want using the sessions. But it sounds like you have a good handle on this part of it. Enjoy! Nate Quote Link to comment Share on other sites More sharing options...
gc40 Posted August 27, 2007 Author Share Posted August 27, 2007 Haha, the mail script was the easiest part of this problem. Its the sessions and storing products in the virtual cart that I am lost on! Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted August 27, 2007 Share Posted August 27, 2007 Read more at the PHP docs - http://www.php.net/session Simply start a session on every page allowing you to access the $_SESSION vars on any page where the session is started. And when the user submits the form save the products to an array or something similar. You can also store their information in the $_SESSION variable (persistent through pages) until they verify the purchase and decided to receive the email. <?php //starts session, MUST be called before sending ANY text to the screen session_start(); //setting Super global session variable ball to true $_SESSION["products"]["ball"] = true; ?> Quote Link to comment Share on other sites More sharing options...
gc40 Posted August 27, 2007 Author Share Posted August 27, 2007 Can you give me an idea of where to start? So the virtual cart would just be calling the sessions of the products that have been added to it? Quote Link to comment Share on other sites More sharing options...
chronister Posted August 27, 2007 Share Posted August 27, 2007 Yeah, the virtual cart is simply the sessions. The cart would be comprised of product id's or something unique to each item in the "cart". e.g. <?php session_start(); $_SESSION['products'][] = 23; $_SESSION['products'][] = 5; ?> With this you could have a display, "Your Cart has <?=count($_SESSION['products']) ?> Items", which would return... Your Cart has 2 items. In this scenario, I am storing the "product id's " in a session array called products. This is the quick and dirty of it, hope it helps. Quote Link to comment Share on other sites More sharing options...
T.R.Cmpbll113 Posted November 30, 2010 Share Posted November 30, 2010 you could check on some pre-built carts like this one: http:www.shoppingcartelite.com and open source carts Quote Link to comment Share on other sites More sharing options...
chronister Posted November 30, 2010 Share Posted November 30, 2010 lol... wow I have never seen one of my responses get re-hashed after 2 and a half years. I hope the original poster has this figured out by now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.