zacthespack Posted August 11, 2011 Share Posted August 11, 2011 I'm looking for a simple shopping cart system for my site to do away with the order form I use at the moment. I have been updating the site which now links each page of products on the site to a mysql table of those products so that I can then export my product data from my sage system straight to the website. What I need is a way for a button to display next to each product that once clicked adds said product to a shopping cart, along with how many of the product the customer wants. the customer once finished then 'checks out' adding there contact information etc. to the order and the order is then sent to my via email. The tricky part is I do not wish payment to be taken this 'shopping cart' would be used just to take orders which will then be processed and paid at a later date. Any help would be great! Thanks Zac Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/ Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 why not just store product id's and quantities in a $_SESSION variable, and display them on a 'shopping cart' page? Then on checkout, they get emailed (or placed in a database) for later processing. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255751 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 why not just store product id's and quantities in a $_SESSION variable, and display them on a 'shopping cart' page? Then on checkout, they get emailed (or placed in a database) for later processing. the site is question is http://www2.acehireltd.co.uk/ we have a very large list of products and so could not simple display them all on one checkout page Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255754 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 ???? you only display the products the client actually wants to buy, not ALL of them. Unless you have clients buying 2000 different products at a time, this shouldn't be a problem. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255757 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 ???? you only display the products the client actually wants to buy, not ALL of them. Unless you have clients buying 2000 different products at a time, this shouldn't be a problem. OK sorry I misunderstood you, my problem is how to set up the checkout as all online help and free systems want payment to be taken at the end or require all the products in one table etc. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255761 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 will depend on what you want to do on checkout. You can just make the checkout button send you an email with the order, you can make it store the order in a database and then send you an email just saying there's a new order, whatever you want. Think simple: It's just a button that can point to any script you want. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255765 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 will depend on what you want to do on checkout. You can just make the checkout button send you an email with the order, you can make it store the order in a database and then send you an email just saying there's a new order, whatever you want. Think simple: It's just a button that can point to any script you want. OK so what I want it to do is, the user presses the button this adds that item to a shopping basket, user can then keep going through the site adding more products then goes to 'check out' at which point they say how many they want, and add in there personal information (address contact number email etc etc) and then submit the order, which gets sent to a email address. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255767 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 ok, cool. start coding, then post your code here and we'll help fix problems. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255770 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 ok, cool. start coding, then post your code here and we'll help fix problems. Thats the problem, I know how to set up the button next to the product sure, but I don't know where to start with the PHP need to select the product info next to the button and put it into the shopping cart Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255772 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 oh dear... Well, you've got to start somewhere... post item details (unique product id and quantity) to a script that will just add them to a $_SESSION array. You can call it something like $_SESSION['shoppingCart']. then create a standalone page that just prints out the values, so you can check if everything is being added correctly. something like: <?php session_start() echo '<pre>'; print_r($_SESSION['shoppingCart']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255775 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 Ok sorry can we start with the button, this is the php I have used to create the table on the website to view the products from the database <?php mysql_connect('localhost', '******', '*********') or die (mysql_error()); mysql_select_db('acehire1_sage') or die (mysql_error()); $result = mysql_query("SELECT * from BBQ LIMIT 0, 12"); //Table starting tag and header cells echo "<table width='650' border='0'><tr bgcolor='#adadad' align='center' valign='top'><th width='65'>Hire Code</th><th width='90'>Picture <font size='2'>(click to enlarge)</font></th><th width='300'>Product Description</th><th width='80'>Hire Cost<br><font size='2'>(Excl. VAT)</font>.</th>"; while($row = mysql_fetch_array($result)){ //Display the results in different cells echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td>" . "</td></tr>"; } //Table closing tag echo "</table>"; ?> This is for this page http://www2.acehireltd.co.uk/bbq so the button will go in the last table column but the link to post the product information to the shopping basket would need to be generated as the information is not static? Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255778 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 add the buttons, add the link (for now point it to a page called addToCart.php) and add a productID to the generated url with the value of $row['productcode']. in addToCart.php just do this for now: <?php session_start(); if(!isset($_SESSION['shoppingCart']){ $_SESSION['shoppingCart'] = array(); } $_SESSION['shoppingCart'][] = $_GET['productID']; // add a redirect script back to the page you were here --- ?> (I'm showing you a simple way of doing things, just to get you on the right track. Later you will need to implement a few more things, checks, security checks, etc... Also, you'll need to add quantities. But since you seem to know very little about php, I though it would be best to start really simple.) at any time, sizeof($_SESSION['shoppingCart']) will tell you the amount of items in there. Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255783 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 OK so I have done this <?php mysql_connect('localhost', 'acehire1_user', 'Authors1') or die (mysql_error()); mysql_select_db('acehire1_sage') or die (mysql_error()); $result = mysql_query("SELECT * from BBQ LIMIT 0, 12"); //Table starting tag and header cells echo "<table width='650' border='0'><tr bgcolor='#adadad' align='center' valign='top'><th width='65'>Hire Code</th><th width='90'>Picture <font size='2'>(click to enlarge)</font></th><th width='300'>Product Description</th><th width='80'>Hire Cost<br><font size='2'>(Excl. VAT)</font>.</th>"; while($row = mysql_fetch_array($result)){ //Display the results in different cells echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td><a href="../addToCart.php">Add</a>" . "</td></tr>"; } //Table closing tag echo "</table>"; ?> However now i get an error on the page "Parse error: syntax error, unexpected '.' in /home/acehire1/public_html/www2/bbq/index.php on line 135", im guessing its because of the ../addToCart.php ? is so how can i link it without php braking Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255785 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 I can tell you know absolutely nothing about php... How do you expect to accomplish this shopping task? echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td><a href="../addToCart.php">Add</a>" . "</td></tr>"; should be echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td><a href='../addToCart.php'>Add</a>" . "</td></tr>"; Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255786 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 thank you, sorry I know basics and have gotten by being able to edit code available on-line. If you feel this project will be to much maybe I should not bother? Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255787 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 your script for the addToCart.php also sends out a error Parse error: syntax error, unexpected '{' in /home/acehire1/public_html/www2/addToCart.php on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255788 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 man, I have no answer for that. Weather or not you should 'bother' is your choice. If you seriously want to code a shopping cart (even just a simple one) you will have to read up a bit more on php. understand how the basics work, the differences between double and single quotes, how to escape characters (and when/why), how variables work, how arrays work, how sessions work, how loops work, how conditions work, and how to send emails. (off the top of my head, the above mentioned should be enough skills for this simple project) Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255790 Share on other sites More sharing options...
zacthespack Posted August 11, 2011 Author Share Posted August 11, 2011 man, I have no answer for that. Weather or not you should 'bother' is your choice. If you seriously want to code a shopping cart (even just a simple one) you will have to read up a bit more on php. understand how the basics work, the differences between double and single quotes, how to escape characters (and when/why), how variables work, how arrays work, how sessions work, how loops work, how conditions work, and how to send emails. (off the top of my head, the above mentioned should be enough skills for this simple project) Ok thank you, I shall look up some guides on this and learn what I can, sorry for wasting your time and thank you for the help Quote Link to comment https://forums.phpfreaks.com/topic/244483-simple-shopping-cart-scripts/#findComment-1255791 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.