Create Simple shopping cart script
Posted: Sun Nov 07, 2004 7:27 pm
I know this has been posted over and over but I'd like to go at it again.
I have commerce-cgi installed on my web site at http://www.16tracks.com and it works ok. But I'm in the proccess of redoing my entire site and I'd like to redo the shopping cart along with it. I don't know Perl and I don't know much PHP either but I am familiar with programming in general.
I'd just like to get some ideas on how to start this project. What I'd like to do is add a form for each item I sell, similar to what I already use.
Here's an example from a guitar page. It shows the Item number (BR-140), the price ($295), shipping cost ($1 and a description. It also has an optional row wich can be selected to included a case with an added cost of $65.
When the "add to cart buton" is pressed, the script generates a new HTML page with a table of items that have been "added to cart". The cart also shows the customer's current total with shipping.
Now I realize that I'm going to have to use cookies or sessions or something (which I know nothing about) but I assume that this will not be needed until the user actually presses one of the "add to cart" buttons. I assume that at this time, a cookie or session will be started. I further realize that cookies may be a bad option because some users may have cookies turned off. So how do I track the user (and his cart) after the first item is added?
I have read enough PHP posts and chapters in books that I think I can do all the echos to print out the HTML code for the cart. I'm just not sure how to get started.
Also, with my current setup, I get an email when a new order is placed. I get all of the customer's shipping and payment info (except that I have to ftp to my site to get half of the credit card number for security reasons.) I'd rather have the entire order (including the credit card number) emailed to me OR maybe more secure - have a page to access to see the lates order info on my web site.
Anyway, can someone help me with the very first part for now? I mean, when an "add to cart" button is clicked for the first time, what do I do? I don't want to use any database. All of the item info will be included in the form.
I have commerce-cgi installed on my web site at http://www.16tracks.com and it works ok. But I'm in the proccess of redoing my entire site and I'd like to redo the shopping cart along with it. I don't know Perl and I don't know much PHP either but I am familiar with programming in general.
I'd just like to get some ideas on how to start this project. What I'd like to do is add a form for each item I sell, similar to what I already use.
Here's an example from a guitar page. It shows the Item number (BR-140), the price ($295), shipping cost ($1 and a description. It also has an optional row wich can be selected to included a case with an added cost of $65.
Code: Select all
<FORM METHOD="POST" ACTION="http://www.16tracks.com/cgi-bin/store/commerce.cgi">
<INPUT TYPE="text" NAME="item-1||295.00|BR-40 Blueridge Acoustic Guitar||18.00" SIZE="3" MAXLENGTH="3" VALUE="1">
<SELECT NAME="option|1|1">
<OPTION VALUE="BR-40|0">BR-40
<OPTION VALUE="BR-40 & Case|65">BR-40 & Case +$65
</SELECT>
<INPUT TYPE="submit" NAME="add_to_cart_button.x" VALUE="Add To Cart">
</FORM>When the "add to cart buton" is pressed, the script generates a new HTML page with a table of items that have been "added to cart". The cart also shows the customer's current total with shipping.
Now I realize that I'm going to have to use cookies or sessions or something (which I know nothing about) but I assume that this will not be needed until the user actually presses one of the "add to cart" buttons. I assume that at this time, a cookie or session will be started. I further realize that cookies may be a bad option because some users may have cookies turned off. So how do I track the user (and his cart) after the first item is added?
I have read enough PHP posts and chapters in books that I think I can do all the echos to print out the HTML code for the cart. I'm just not sure how to get started.
Also, with my current setup, I get an email when a new order is placed. I get all of the customer's shipping and payment info (except that I have to ftp to my site to get half of the credit card number for security reasons.) I'd rather have the entire order (including the credit card number) emailed to me OR maybe more secure - have a page to access to see the lates order info on my web site.
Anyway, can someone help me with the very first part for now? I mean, when an "add to cart" button is clicked for the first time, what do I do? I don't want to use any database. All of the item info will be included in the form.