Home PHP

PHP SHOPPING CART SYSTEM – Source Code – Download Now!

php-shopping-cart-source-code-download
Are you trying to learn how to build your own PHP shopping cart system? Do you need a quick guidance and support while doing it? You’re in the right place.

Google defines the word “system” as a set of connected parts forming a complex whole. We say this “PHP shopping cart source code” is a “system” because of that definition.dat

Each module of this source code is designed to be very simple and easy to understand. It is based on our step-by-step CRUD tutorials, like this one.

You will be able to build a complex web application before you know it. You’ll never get lost. It is your advantage. You can use the same knowledge to build another type of web application.

We are here to help you in anything you do not understand in this source code.

Download and learn how this PHP Shopping Cart System was made. Technologies used include PHP, MySQL, jQuery, AJAX, Bootstrap, HTML5, Object-oriented programming and more.

This project is not perfect. It is designed to be simple. This is a very good starting point of your development.

DOWNLOAD NOW
If you’ve been here before, you read the details about this product and you already know its value. You can download by choosing the right package and clicking the download button below.

Download Now

Contents of this post include:

1.0 Source Code Overview
2.0 Output Preview & Demo Link
3.0 Is This Code For Me?
4.0 Pre-Requisites
5.0 Cart Data Storage
6.0 Database Design
7.0 File Structure
8.0 What People Say
9.0 Features List & Download
10.0 Simple Set Up
11.0 Thanks For Your Help!
12.0 Related Source Codes
13.0 Get In Touch

1.0 Source Code Overview

This source code will enable you to make your own PHP shopping cart system. This source code is a very good starting point if you’re trying to build your own ‘PHP Shopping Cart Source Code’ from scratch and add some more complex features later.

This is because the basis of this source code are our step by step and easy to understand tutorial. Specifically this tutorial: PHP, MySQL and OOP CRUD Tutorial – Step by Step Guide!

The system looks simple. But I assure you that when you study the source code, you will learn a lot of useful PHP coding techniques.

Some include: Ordering and inventory features, PayPal integration, web page content management, product management, variation, collecting and storing customer messages on your own database, admin restrictions and more! You can see the detailed list of features on section 9.0 below.

2.0 Output Preview & Demo Link

Below are some screenshots of our script’s output. You can click an image to view the larger version of it. Use the left and right arrow to navigate through the screenshots.

Please note that the following images are just output previews. New features might be added already the time you are reading this.

Output preview when customer is not logged in.


Output preview when customer is logged in.


Output preview when admin / merchant is logged in.


If you need the live demo link, send a request to mike@codeofaninja.com with subject “DEMO Request: PHP Shopping Cart System”, thank you!

3.0 Is This Code For Me?

The source code in this page is NOT for you if:

  • You are already an expert in PHP & MySQL programming.
  • You have a lot of time to code the listed features of our PHP shopping cart source code
  • You are not that interested in learning PHP & MySQL programming.

But, this SOURCE CODE is FOR YOU if:

  • You want to SAVE a significant amount of development time.
  • You want to develop your own PHP Shopping Cart Source Code from scratch.
  • You determined to learn how to make a this web application feature in PHP & MySQL.
  • You need some guidance in learning about this script (I’ll personally support you & answer your questions)

But if you are an expert in PHP & MySQL programming and would like to take a look at our code, please do so! We’d love to hear your response and great insights! The comments section below is always open for anyone with questions and suggestions.

4.0 Pre-Requisites

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

a. PHP, MySQL & OOP CRUD Tutorial – Step By Step Guide!
b. Apache .htaccess RewriteRule Examples with PHP
c. PHP, MySQL & AJAX CRUD Tutorial – Step By Step Guide!

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

6.0 Database Design

Our database name will be “shop_cart_complete”, and we will have twelve (12) tables.
database-design-php-shopping-cart-source-code

7.0 File Structure

The following folders and files are included in the source code. It will have more meaning if you will see the code inside the folders and files.
├─ admin/
├─── category.php
├─── change_order_status.php
├─── change_password.php
├─── create_category.php
├─── create_page.php
├─── create_product.php
├─── create_user.php
├─── create_variation.php
├─── delete_category.php
├─── delete_image.php
├─── delete_message.php
├─── delete_page.php
├─── delete_pdf.php
├─── delete_product.php
├─── delete_user.php
├─── delete_variation.php
├─── layout_foot.php
├─── layout_head.php
├─── login_checker.php
├─── navigation.php
├─── order_history.php
├─── paging.php
├─── read_categories_template.php
├─── read_categories.php
├─── read_inactive_products.php
├─── read_message.php
├─── read_messages_template.php
├─── read_messages.php
├─── read_one_order.php
├─── read_orders_template.php
├─── read_orders.php
├─── read_pages_template.php
├─── read_products_sorted_by_fields.php
├─── read_products_template.php
├─── read_products.php
├─── read_users_template.php
├─── read_users.php
├─── search_categories.php
├─── search_messages.php
├─── search_orders.php
├─── search_pages.php
├─── search_products.php
├─── search_users.php
├─── settings.php
├─── update_category.php
├─── update_page.php
├─── update_product.php
├─── update_user.php
├─── update_variation.php
├─── variations.php
├─ config/
├─── core.php
├─── database.php
├─ dev/
├─── shop_cart_complete.sql
├─── readme.txt
├─ images/
├─ libs/
├─── css/
├────── bootstrap/
├────── font-awesome/
├────── admin.css
├────── user.css
├─── js/
├────── bootstrap-image-gallery/
├────── jquery-ui/
├────── responsive-filemanager/
├────── tinymce/
├────── bootbox.min.js
├────── custom-script.js
├────── jquery.js
├─── php/
├────── php-mailer/
├────── pw-hashing/
├────── paypal_checkout.php
├────── utils.php
├─ objects/
├─── cart_item.php
├─── category.php
├─── message.php
├─── order_item.php
├─── order.php
├─── page.php
├─── product_image.php
├─── product_pdf.php
├─── product.php
├─── setting.php
├─── user.php
├─── variation.php
├─ uploads/
├─── images/
├─── pdfs/
├─ .htaccess
├─ add_to_cart.php
├─ cart.php
├─ category.php
├─ change_password.php
├─ checkout.php
├─ contact.php
├─ delete_cookie.php
├─ edit_profile.php
├─ add_to_cart.php
├─ cart.php
├─ category.php
├─ change_password.php
├─ checkout.php
├─ contact.php
├─ delete_cookie.php
├─ edit_profile.php
├─ empty_cart.php
├─ forgot_password.php
├─ info.php
├─ layout_foot.php
├─ layout_head.php
├─ load_variation.php
├─ login_checker.php
├─ login.php
├─ logout.php
├─ navigation.php
├─ orders.php
├─ page.php
├─ paging.php
├─ place_order.php
├─ product.php
├─ products.php
├─ read_one_order.php
├─ read_products_sorted_by_fields.php
├─ read_products_template.php
├─ register.php
├─ remove_from_cart.php
├─ reset_password.php
├─ search.php
├─ update_quantity.php
├─ navigation.php
├─ verify.php

8.0 What People Say

Here are some of the things people say about our source code downloads.

★★★★★ “I have purchased both your (PHP) CRUD Level 2, and Level 3 applications so that I can improve my programming skills. YOU’RE THE MAN! I would say that I should have contacted you three days ago, I learned a lot!!!”

Kevin Richards
Web Developer, Recruiter Solutions

★★★★★ “Mike, thank you for the great (PHP CRUD) tutorial and quick response, I finally figured it out and got it working!”

Ira Rabinowitz
Web Developer & Designer, LinkedIn Profile

★★★★★ “Awesome! everything is looking great (PHP Shopping Cart). You’re my new hero this is all great. We couldn’t be happier. You will be paid more.”

Joshua Duncan
Product Manager, LinkedIn Profile

9.0 Features List & Download

FEATUREACCESS LEVELSOURCE CODE
USER MANAGEMENT
Create userAdminYES
Read usersAdminYES
Update userAdminYES
Delete userAdminYES
Search userAdminYES
Users list paginationAdminYES
Valid email format requiredAdmin & CustomerYES
Password must be uppercase letter, lowercase letter, number and special characterAdmin & CustomerYES
Confirm password fieldAdmin & CustomerYES
Password validation as you typeAdmin & CustomerYES
View customer order historyAdmin & CustomerYES
Deleting first administrator account is not allowedAdminYES
User types: Admin and CustomerAdmin & CustomerYES
Interface for adminAdminYES
Interface for customerCustomerYES
Login pageAdmin & CustomerYES
Log outAdmin & CustomerYES
Sign up pageCustomerYES
Sign up email notification with validation linkCustomerYES
Edit profile of currently logged in userAdmin & CustomerYES
Show name with icon of currently logged in userAdmin & CustomerYES
Forgot password – system can send unique reset password link via emailCustomerYES
Forgot password – user can click the unique verification link and reset his passwordCustomerYES
PRODUCT MANAGEMENT
Create productAdminYES
Read productsAdminYES
Update productAdminYES
Delete productAdminYES
Search productAdmin & CustomerYES
Product lists with paginationAdmin & CustomerYES
View inactive productsAdminYES
View products under a categoryAdmin & CustomerYES
Product list under a category with paginationAdmin & CustomerYES
Upload product images, you can select many images at onceAdminYES
View product images with thumbnailsAdmin & CustomerYES
Delete product image with X iconAdminYES
Upload product PDFs , you can select many PDF files at onceAdminYES
List product PDFAdminYES
Delete product PDFAdminYES
View single product with related informationCustomerYES
View single product with add to cart buttonCustomerYES
View single product with image sliderCustomerYES
View single product with SEO friendly URL (.htaccess file used)CustomerYES
Rich text editor for product description when adding or editing productAdminYES
Quantity value must be more than 1CustomerYES
Sorting by fieldsAdmin & CustomerYES
VARIATION MANAGEMENT
Set variation nameAdminYES
Set variation priceAdminYES
Set variation stockAdminYES
Stock / inventory decreases when order has been placedAdminYES
Increase stock / inventory by updating the variationAdminYES
Create variationAdminYES
Read list of variationAdminYES
Update variationAdminYES
Delete variationAdminYES
CATEGORY MANAGEMENT
Create categoryAdminYES
Read categoriesAdminYES
Update categoryAdminYES
Delete categoryAdminYES
Search categoryAdminYES
Category list with paginationAdminYES
Category search result with paginationAdminYES
View products under a product categoryAdmin & CustomerYES
Auto update category drop down in create or update product formAdminYes
Auto update categories in navigation barAdmin & CustomerYES
Highlight selected category in navigationAdmin & CustomerYES
ORDER MANAGEMENT
Make an orderCustomerYES
Auto-generated unique transaction IDCustomerYES
Add to cart button (for each item) with specified quantityCustomerYES
Cart page with list of products added to cartCustomerYES
Update quantity button for each item in cart pageCustomerYes
Auto-compute subtotal in cart pageCustomerYES
Auto-compute grand total in cart pageCustomerYES
Remove from cart button for each item in the cartCustomerYES
Empty cart button to remove all items in the cartCustomerYES
View order history of a customerAdmin & CustomerYES
View pending and completed order in separate tabsAdminYES
Checkout pageCustomerYES
Show billing information on check-out pageCustomerYES
Edit billing information button on checkout pageCustomerYES
Show payment information on checkout pageCustomerYES
Payment via cash on deliveryCustomerYES
Payment via PayPalCustomerYES
Place order page – Thank you messageCustomerYES
View list of ordersCustomerYES
Pagination on list of ordersAdmin & CustomerYES
Latest order seen at the top of the listAdmin & CustomerYES
View details of an orderAdmin & CustomerYES
Auto-compute order totalsAdmin & CustomerYES
Change status of an order (pending or completed)AdminYES
SECURITY
Register user hashed password stored in the databaseCustomerYES
Edit user profile hashed password update in the databaseAdminYES
Create user hashed password stored in the databaseAdminYES
Login user with hashed password validationCustomer & AdminYES
Used PDO bindParam() to prevent SQL injection in all MySQL queriesDeveloperYES
Used PHP htmlspecialchars() to prevent XSS attacksDeveloperYES
WEB PAGE MANAGEMENT
Create pageAdminYES
Read pageAdminYES
Update pageAdminYES
Delete pageAdminYES
Search pageAdminYES
Pages list with paginationAdminYES
Pages search result with paginationAdminYES
CONTACT MANAGEMENT
Send message to AdminCustomerYES
Display other ways to contact AdminCustomerYES
Display list of messagesAdminYES
Messages list with paginationAdminYES
Read messageAdminYES
Delete messageAdminYES
Search messageAdminYES
Messages search result with paginationAdminYES
MORE REASONS TO DOWNLOAD IT
Object oriented programming source codeDeveloperYES
Bootstrap user interfaceDeveloperYES
PDO extension usedDeveloperYES
Page title navigation with linksDeveloperYES
Radio button looks like a switchDeveloperYES
Icon in all create, edit and delete buttonsDeveloperYES
All source code files organized by foldersDeveloperYES
Database configuration file in config folderDeveloperYES
SQL file and READ-ME.txt that contains login credentials in “sql” folderDeveloperYES
Well explained / commented source codeDeveloperYES
One-time payment, no recurring paymentDeveloperYES
UPDATES AND SUPPORT
Free source code updates for 2 yearsDeveloperYES
Free support for 6 monthsDeveloperYES
Download Now

10.0 Simple Set Up

You can run this source code successfully with few easy steps.

10.1 Run the Home Page

The home page of this source code is NOT index.php – the home page is products.php, so how do we run products.php successfully?

1. In your PhpMyAdmin, create a database with a name “shop_cart_complete”.

2. Import the “shop_cart_complete.sql” SQL file from the “dev” folder.

3. Change rewrite base directory in line 7 of .htaccess file.

4. Configure $home_url in /config/core.php, example $home_url values are:

$home_url="https://www.yourwebsite.com/"

or

$home_url="http://localhost/shopping-cart-system/"

5. Configure database in /config/database.php, example settings would look like:

private $host = "localhost";
private $db_name = "shop_cart_complete";
private $username = "shop_complete";
private $password = "your_db_pw_143";

6. Try to login by running login.php and using the following login credentials.

Admin Section Login
Username: mike@example.com
Password: ninja12qw!@QW

Customer Account Login
Username: darwin@example.com
Password: darwin12qw!@QW

10.2 How To Set Up / Enable Auto Return?

With Auto Return for PayPal Website Payments, your buyers are redirected back to your site immediately after clicking the Pay button on the Payment Confirmation page.

Your buyers enjoy a streamlined checkout experience and are returned back to your site quickly!

1. Enable Auto Return In Your Test / Sandbox Account.

  1. Log into https://developer.paypal.com
  2. Click Applications
  3. Click Sandbox accounts
  4. Expand the account in question
  5. Click Sandbox site
  6. Login to the test account
  7. Copy and paste “https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-payments” into your browser
  8. Enable Auto Return and click Save
  9. Enter the Auto Return URL and click Save

[Reference]

2. Setting Up Auto Return On Your Official / Real PayPal Account

  1. Log in and click the Profile subtab under My Account.
  2. Click the Website Payment Preferences link under Selling Preferences.
  3. Click the On radio button to enable Auto Return.
  4. Enter the Return URL. Note: You must meet the Return URL requirements in order to set up Auto Return. Learn more about Return URL.

[Reference]

3. How To Disable Sandbox Mode?
This source code is in sandbox mode by default, it means any PayPal transactions are for testing purposes only. To disable PayPal Sandbox mode:

  1. Open /libs/php/paypal_checkout.php
  2. Change line 51, from
    $form='<form id="paypal_checkout" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
    

    to

    $form='<form id="paypal_checkout" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    
  3. Change email address in line 5 to your real PayPal account email address. Payment will be sent to the specified PayPal account.

10.3 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"},

10.4 Some More Notes

1. This system works with PHP 5.4+

2. Rewrite module must be enable in your apache server (this is enabled by default in most web servers and localhost)

11.0 Thanks For Your Help!

YES! The shopping cart system source code is now available! Thanks for all the pre-orders and support! More features and enhancements will be added in the future.

I’ll keep you updated via email with the update information and download link. Download the source code by clicking the green BUY button below.

Download Now

12.0 Related Source Codes

Related Source Code Modules

You can download the PHP SHOPPING CART SYSTEM by modules. Learn more by clicking any 'View Module' button below.

ModulesAction
PHP Users & Login System
PHP Product Catalog
PHP Shopping Cart & Ordering
PHP Web Page Content Management
PHP Contact Form & Messages
PHP & PayPal Integration

You can download the different modules right now by checking multiple check-boxes and clicking the "Download Now" button below.

Download Now

13.0 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 mike@codeofaninja.com, 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. CLICK HERE TO SUBSCRIBE!

Thank you for visiting our for PHP shopping cart source code download page!