PHP Shopping Cart Module




Before you download, make sure you have basic understanding of these topics:

a. PHP Object Oriented CRUD Example with Bootstrap
b. Apache .htaccess RewriteRule Examples with PHP

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.

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."

"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!"

"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."

Features List & Download

Create user Admin YES
Read users Admin YES
Update user Admin YES
Delete user Admin YES
Search user Admin YES
Users list pagination Admin YES
Valid email format required Admin & Customer YES
Password must be uppercase letter, lowercase letter, number and special character Admin & Customer YES
Confirm password field Admin YES
Password validation as you type Admin YES
View customer order history Admin & Customer YES
Deleting first administrator account is not allowed Admin YES
User types: Admin and Customer Admin & Customer YES
Interface for admin Admin YES
Interface for customer Customer YES
Login page Admin & Customer YES
Log out Admin & Customer YES
Edit profile of currently logged in user Admin YES
Show name with icon of currently logged in user Admin & Customer YES
Create product Admin YES
Read products Admin YES
Update product Admin YES
Delete product Admin YES
Search product Admin & Customer YES
Product lists with pagination Admin & Customer YES
View inactive products Admin YES
View products under a category Admin & Customer YES
Product list under a category with pagination Admin & Customer YES
Upload product images, you can select many images at once Admin YES
View product images with thumbnails Admin & Customer YES
Delete product image with X icon Admin YES
Upload product PDFs , you can select many PDF files at once Admin YES
List product PDF Admin YES
Delete product PDF Admin YES
View single product with related information Customer YES
View single product with add to cart button Customer YES
View single product with image slider Customer YES
View single product with SEO friendly URL (.htaccess file used) Customer YES
Rich text editor for product description when adding or editing product Admin YES
Quantity value must be more than 1 Customer YES
Sorting by fields Admin YES
View products under a product category Admin & Customer YES
Highlight selected category in navigation Admin & Customer YES
Make an order Customer YES
Auto-generated unique transaction ID Customer YES
Add to cart button (for each item) with specified quantity Customer YES
Cart page with list of products added to cart Customer YES
Update quantity button for each item in cart page Customer YES
Auto-compute subtotal in cart page Customer YES
Auto-compute grand total in cart page Customer YES
Remove from cart button for each item in the cart Customer YES
Empty cart button to remove all items in the cart Customer YES
View order history of a customer Admin & Customer YES
View pending and completed order in separate tabs Admin YES
Checkout page Customer YES
Show billing information on check-out page Customer YES
Show payment information on checkout page Customer YES
Payment via cash on delivery Customer YES
Place order page – Thank you message Customer YES
View list of orders Customer YES
Pagination on list of orders Admin & Customer YES
Latest order seen at the top of the list Admin & Customer YES
View details of an order Admin & Customer YES
Auto-compute order totals Admin & Customer YES
Change status of an order (pending or completed) Admin YES
Register user hashed password stored in the database Customer YES
Edit user profile hashed password update in the database Admin YES
Create user hashed password stored in the database Admin YES
Login user with hashed password validation Customer & Admin YES
Used PDO bindParam() to prevent SQL injection in all MySQL queries Developer YES
Used PHP htmlspecialchars() & strip_tags() to prevent XSS attacks Developer YES
Object oriented programming source code Developer YES
Bootstrap user interface Developer YES
PDO extension used Developer YES
Page title navigation with links Developer YES
Radio button looks like a switch Developer YES
Icon in all create, edit and delete buttons Developer YES
All source code files organized by folders Developer YES
Database configuration file in config folder Developer YES
SQL file and READ-ME.txt in “dev” folder Developer YES
Database design and data dictionary in “dev” folder Developer YES
Well explained / commented source code Developer YES
Free support for 6 months Developer YES
Free source code updates. Developer YES
Buy once, use for unlimited number of sites Developer YES
One-time payment, no recurring payment Developer YES
$50 – Download source code

Simple Set Up

Source code simple set up when you install:

1. Extract the ZIP file to your server directory.

2. In your PhpMyAdmin, create a database “shop_cart_module”

3. Import the “shop_cart_module.sql” SQL file in the “dev” folder

4. Change rewrite base directory in line 7 of .htaccess file (if needed)

5. Change $home_url in /config/core.php (if needed)

6. Configure database in /config/database.php

7. Run product.php – this is the main file, not index.php

8. User Login
Admin Section Login
Username: [email protected]
Password: [email protected]

Customer Account Login
Username: [email protected]
Password: [email protected]

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_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!

Categorized as PHP

By Mike Dalisay

I'm Mike Dalisay, a pro web developer since 2010. I love web development. Improving our tutorials and source codes makes me happy. Do you want to suggest an edit to our tutorial? Got something to ask about our source codes? Email our team at [email protected]