Shopping Cart Tutorial PHP Shopping Cart Tutorial
Learn how to create an online store with PHP and MySQL
Free shopping cart    Download:
Shop-Script FREE
Shop-Script FREE User Guide (PDF; 0 Kb)
View Live Demo    View online store demo
 Introduction
 Basic concepts
 Technologies
 File structure
 Database structure
 Back end
   Password protection
   Products catalog: structure
   Product catalog: viewing
   Managing categories
   Managing products
   Special offers
   Managing orders
 Front end
   Viewing products catalog
   Product search
   Shopping cart
   Checkout
   PayPal integration
 Security
 Live Demo
 Author
 Terms Of Use

Shopping cart software

 

Bringing products catalog to customers

Presenting products catalog to customers is much like presenting products and categories in back end.

To navigate in products catalog customer can use a category tree:

When clicking a certain category link, customer is directed to

index.php?categoryID=X

where X is the integer ID of the category, e.g. 5.

Script should perform following operations if categoryID parameter is passed:

  1. Validates categoryID parameter value and transforms it to an integer number to avoid SQL injections vulnerability. More about your store security .
  2. Searches for a requested category in the database.
  3. If category was not found in the database, visitor is redirected to storefront homepage (index.php).
  4. If category was found, visitor is shown a list of products within selected category with the ability to order certain products.

A list of products within current category can be easily fetched from the database using following SQL query:

SELECT * FROM `PRODUCT` WHERE categoryID = `$current_categoryID`;

Clicking a certain product link brings visitor detailed product information page - index.php?productID=XX.
XX indicates unique integer ID of the product.
Just like with the category, script should validate productID parameter value, search for a product in the database, and then fetch all required information from the database and present it to visitor:

 

Clicking "Add to cart" button will add this product to customer's shopping cart. Learn more about shopping cart feature.

 

 


Copyright © 2006 WebAsyst LLC