Loading

How to Build Shopping Cart w/ Checkout in PHP

Submitted by: 
Language: 
Visitors have accessed this post 21464 times.


I just rewrite the code included in this post to fix minor problem encounter by other PHP programmers who can’t run the shopping cart.

The code is taken from this link: http://www.qualitycodes.com/tutorial.php?articleid=25&title=Tutorial-Building-a-shopping-cart-in-PHP.

As you may have noticed, a lot of programmers are screaming for help on how to fix some bugs on this tutorial. Since I cannot upload the code in the said website, I decided to post it here. Still credit goes to “Richard Clark”.

Changes on the code are following:

  1. Change “<?” to “<?php” to handle php correctly. Some old program still uses “<?” to run PHP code. However, PHP 5 is not stricter and requires you to use php after <?, unless you configure Apache to allow such a shorthand support.
  2. Add echo command instead of equal (=) sign.

Note: If you run the code prior to downloading this code, make sure to clear your browser cache.




Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Hello,

I've tried uploading the files directly to my web server, but it still produces errors and not the shopping cart. Is there something I should be doing differently such as uploading the sql file elsewhere?

please solve my problem after using the How to Build Shopping Cart w / Checkout in PHP is, after I tried to check out why the data from a shopping cart in the shopping cart data is still there? thank... please replay by email rohman_aenur@yahoo.co.id

sir thanks for this awesome tutioral....i realy appreciate you but i have a problem......i have three product categories....so i had used three products table,three products page, 3 shopping cart pages.......but the problem when only one product works ........but when i open second page.........nd select add to cart........shopping cart does not get name,price,description...only show quantinty and serial.........other fields remain blank...........although other option like update,clear,and remove is working properly..............please help me :(

I admire this programer to make shopping cart with ckeckout system.

this was extremely helpful. I am trying to make my first e-comm project.. it was a great help. thanks.

Thanx!! a lot for this readymade scripting of shopping cart..
Thanx........

hi...can you explain this...
include("includes/db.php");
include("includes/functions.php");
please...help me..

Hello Sir,

Quick question if you can please help me. I want to pass a variable to the shoppingcart.php coming from products.php so that when the customer clicks on "Continue Shopping" it will put the customer back to the products page based on that variable. Basically I call the products page like this for example the $dealID value is 37 "products.php?dealID=37". That part works just fine my problem is when I put the item on the shopping cart when I click on continue shopping I need it to go back to "products.php?dealID=37" but I cant seem to make the shopping cart load the $dealID variable

I hope you can help me with this.

when i going to the shoppingcart.php it come out those errors. Please help ASAP..thanks

Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 5

Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 8

Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 11

Notice: Undefined variable: msg in
C:\xampp\htdocs\cart\shoppingcart.php on line 63

admin's picture

Try to change the error reporting in your php.ini to:

error_reporting = E_ALL & ~E_NOTICE

Let me know if the error still exist.

thank you very much :)

Good day. Im blessed to have your free ready code .
Thanks a lot it really helps to our project in web :)

How should i link the shopping cart to the email?
After checkout it should send a mail with all the items in the cart instaed of going for payment.
Please help.

plz help me how to show that specfic image to cart when i pressed add to cart

pls tell me how to solve. this ( ! ) Notice: Undefined index: command in C:\wamp\www\shopping cart_rtmh\shoppingcart.php on line 4 how to solve.
Notice: Undefined index: cart in C:\wamp\www\shopping cart_rtmh\shoppingcart.php

admin's picture

Read this:

http://www.sourcecodester.com/comment/31051#comment-31051

many many thanks

Notice: Undefined index: command in C:\wamp\www\products.php on line 5
Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 5

Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 8

Notice: Undefined index: command in C:\xampp\htdocs\cart\shoppingcart.php on line 11

Notice: Undefined variable: msg in
C:\xampp\htdocs\cart\shoppingcart.php on line 63
Notice: Undefined index: command in C:\wamp\www\shopping cart_rtmh\shoppingcart.php on line 66

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.