Table of Contents
Hi, friend today I am writing tutorial on cart system. Well ,if you are a programmer or just fresher ,taking training somewhere, you know that making e-commerce/shopping cart site (cart system ) is so famous. Maximum company required that things.
For better explanation i have divided major sections to.
section 1: Creating products display category wise
For this we have to create 2 table in our MySQL database
you can find below sql query to create 'category' table
SQL query to create 'products' table
If you looking for best PHP , Mysql course ,visit here .
To use this ,you should have a database , if you have not created , create it now. Then execute the above query in phpmyadmin 'SQL' tab after selecting your databse.
So , we have created table for 'category' and 'products'. Now have to add data .For this we need category_add.php and product_add.php
Find below code for this.
category_add.php
product_add.php
Section: 2 Showing Products in frontend
Previously we have created category and products table ,then added some data in it.Now time to show these in our site. let's create our php project .For this we need to have any HTML template .We need to setup our HTML template to PHP.Now inside 'includes' folder we have left.php file .Open it in any php editor and put following code where you want to display your categories.
Now if we click on left category ,there should open product of the category. Section: 3 Cart system
managing cart system is not so complicated. Just have to create a 'cart' table and do some mysql query to add data into this . To create cart table execute following sql code in phpmyadmin
Creating add to cart system in our products.php. Write below code in this page.
I have created add to cart in oops .So find below the class 'cart'.This code can put inside 'class.php' inside 'includes' folder .Then call it in your template 'header.php' file .Do not forget to create object of the class to use it's method.
So now if we click on 'add to cart' button in products.php page ,the product will be added to cart table along with member mid. Section: 4 Cart.php to show cart data
Finally we are in cart.php file .Here we have to show all our cart data. Use below code to show cart products details.
So, Finally we have build a cart system . For complete e-commerce site ,there lots of section still required like delivery information page, order review page ,payment gateway implementation etc.I will write tutorial for these soon .Hope this tutorial will help any beginners for understanding core PHP shopping cart system with MySQL database.For complete E-commerce project based Web Development Training visit our site