PHP Shopping Cart Module
This PHP shopping cart module has features of a shopping cart that works with a logged in user. This is a good starting point of developing your project. You can add your own features that is required for your project.
List of features
Admin features
The table below shows the features an admin can do in the system.
ADMIN FEATURES |
---|
User Management |
Create, read, update, delete and search users |
List users with pagination |
Valid email format required |
Password must be an uppercase letter, lowercase letter, number, and special character |
Confirm password field |
Password validation as you type |
View customer order history |
Deleting the first administrator account is not allowed |
Edit profile of currently logged in user |
Show name of currently logged in user |
Login page and logout function |
Product Management |
Create, read, update, delete and search users |
List products with pagination |
View inactive products |
View products under a category |
List products under a category |
Upload product images, you can select many images at once |
View product images with thumbnails |
Delete product image with the X icon |
Upload product PDFs, you can select many PDF files at once |
List and delete product PDF |
Rich text editor enabled for product description when adding or editing product |
Quantity value must be a number and greater than or equal to 1 |
Sort products by fields |
Highlight the selected category in the navigation |
Order Management |
View pending and completed orders in separate tabs |
Change status of an order (pending or completed) |
Pagination on the list of orders |
The latest order is seen at the top of the list |
View details of an order |
Auto-compute order totals |
Customer features
The table below shows the features a customer can do in the system.
CUSTOMER FEATURES |
---|
User Management |
Login page and logout function |
Password must be an uppercase letter, lowercase letter, number, and special character |
Valid email format required |
Edit profile of currently logged in customer |
Show name of currently logged in user |
Product management |
Product lists with pagination |
Search products with paginated results |
View products under a category |
Product list under a category with pagination |
View product images with thumbnails |
Product page with related information, add to cart button, and image slider |
View single product with SEO friendly URL (.htaccess file used) |
Quantity value must be a number and equal to or greater than one |
Highlight selected category in the navigation bar |
Order Management |
Make an order |
Auto-generated unique transaction ID |
Add to cart button (for each item) with specified quantity |
Cart page with a list of products added to cart |
Update quantity button for each item on the cart page |
Compute subtotal and grand total on the cart page |
Remove from cart button for each item in the cart |
Empty cart button to remove all items in the cart |
View customer order history with pagination |
A checkout page with billing information |
Payment via cash on delivery |
Place order page – Thank you message |
The latest order is seen at the top of the list |
View details of an order |
Developer features
The table below shows the features that developers like you will like.
DEVELOPER FEATURES |
---|
Hashed passwords stored in the database |
Uses PDO bindParam() to prevent SQL injection in all MySQL queries |
Uses PHP htmlspecialchars() & strip_tags() to prevent XSS attacks |
Object oriented programming source code |
Bootstrap user interface |
PDO extension used |
Radio button looks like a switch |
All source code files organized by folders |
Database configuration file in "config" folder |
SQL file and READ-ME.txt in “dev” folder |
Free support and code updates for 1 year |
Before you download
Make sure you have a basic understanding of the our PHP OOP CRUD Tutorial and .htaccess RewriteRule Examples.
Our source code is provided as-is. We can support only the features listed above. We currently do not accept custom programming job. Thank you for understanding!
Download source code
Please use the button below to download our PHP Shopping Cart Module source code.
What People Say?
Here's what people feel about our work and source code downloads
"Wow, I love you guys! The best web programming tutorial I’ve ever seen. So comprehensive, yet easy to follow. I love how you combine all necessary elements in such a neat structure." ~ Olaug Nessa
"The fact that you’ve put it all together saves so much time and its worth buying the code. Makes me feel good supporting a developer like yourself. Keep up the good work!" ~ Dan Hudson
"Thanks for making these awesome tutorials! I bought your source codes. To be honest, it’s very readable code and helps me understand a lot of things and how it’s done in PHP. Thanks for that again." ~ Michael Lammens
Cart Data Storage
This source code takes advantage of PHP SESSIONS, PHP COOKIES, and MySQL when storing cart data.
- We use PHP COOKIES to save site visitor's user_id locally.
- We use PHP SESSIONS as back up just in case cookies are disabled in user's browser.
- We use MySQL to store cart items in the database.
- This way, cart items can be resurrected even if user closed his browser, logged out or logged in another computer.
Here's the logic:
IF cookies are enabled, AND if user is logged in, we save 'session user_id' to 'user_id variable'. The value of 'user_id variable' is very important because we use it to save 'user_id' both in PHP 'cookie' and 'session'.
IF cookies are enabled, AND if user is not logged in, AND if user already have a 'cookie user_id' token, we save 'cookie user_id' to 'user_id variable'.
IF cookies are enabled, AND if user is not logged in, AND if 'cookie user_id' is not set (it means, visitor never used the cart before), we get new token as 'user_id variable' value.
IF cookies are enabled, AND user is logged in OR not logged in, we set 'cookie user_id' and 'session user_id' with the final 'user_id variable' value. This will retrieve the cart data with the same 'user_id' from MySQL database.
IF cookies are disabled, AND user is logged in, we maintain 'session user_id'.
IF cookies are disabled, AND user is not logged in, we get new token and save it to 'session user_id'.
Important Note: The statements above can be understood more clearly if you will see the code implementation on /config/core.php line 26 onwards.
Simple Set Up
Source code simple set up when you install:
- Extract the ZIP file to your server directory.
- In your PhpMyAdmin, create a database "shop_cart_module"
- Import the "shop_cart_module.sql" SQL file in the "dev" folder
- Change rewrite base directory in line 7 of .htaccess file (if needed)
- Change $home_url in /config/core.php (if needed)
- Configure database in /config/database.php
- Run product.php - this is the main file, not index.php
- Admin account
Username: [email protected]
Password: ninja12qw!@QW - Customer account
Username: [email protected]
Password: darwin12qw!@QW
How To Make TinyMCE File Manager / File Browser Work?
1. Change line 71 of /libs/js/responsive_filemanager/filemanager/config/config.php
'upload_dir' => '/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/source/',
2. Change line 42-43 of /admin/layout_foot.php
external_filemanager_path:"/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/filemanager/",
external_plugins: { "filemanager" : "/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/filemanager/plugin.min.js"},
I'll keep you updated via email with the updated information and download link. Download the source code by clicking the green button below. Once your payment was sent, you'll receive the download link in your email.
Need More Features?
If you think you now need more features, you can download our PHP Shopping Cart System instead. It has more features like web page content management, contact form, and more.
Related Source Code Modules
You can download the PHP SHOPPING CART SYSTEM by modules. Learn more by clicking any 'View Module' button below.
Modules | Action |
---|---|
PHP Login & Registration Module | |
PHP Shopping Cart Module | |
PHP Product Catalog Module | |
PHP Content Management Module | |
PHP Contact Form Module | |
PHP PayPal Integration Module |
Get In Touch
Contact me if you have any questions about the code, I'll be more than happy to help and support you! My email is [email protected], you can also contact me via our official Facebook page.
Please subscribe as well to receive news and updates about our source codes and free tutorials. Fill out the form below.
Thank you for visiting our PHP Online Shopping Cart Source code download page!
Hi! I'm Mike Dalisay, the co-founder of codeofaninja.com, a site that helps you build web applications with PHP and JavaScript. Need support? Comment below or contact [email protected]
I'm also passionate about technology and enjoy sharing my experience and learnings online. Connect with me on LinkedIn, Twitter, Facebook, and Instagram.