PHP Shopping Cart.

Shopping Cart with PHP and e-commerce Paypal Checkout.

Angular JS
php angular shop shopping cart basket buy shopping cart

How to build a PHP Shopping Cart?

First we will create the database with php myadmin. You can do it locally or on your webserver.

Secondly, you paste this code inside the query of php myadmin.
You should have a table with the name 'products' and rows: `id`, `product_code`, `product_name`, `product_desc`, `product_img_name`, `price`.

  `product_code` varchar(60) NOT NULL,
  `product_name` varchar(60) NOT NULL,
  `product_desc` tinytext NOT NULL,
  `product_img_name` varchar(60) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `product_code` (`product_code`)

-- Dumping data for table `products`

INSERT INTO `products` (`id`, `product_code`, `product_name`, `product_desc`, `product_img_name`, `price`) VALUES
(1, '001', 'Lesson 1', 'Angular lesson 1', 'angular.svg', 10.00),
(2, '002', 'Lesson 2', 'Angular lesson 2', 'angular.svg', 7.00),
(3, '003', 'Lesson 3', 'Angular lesson 3', 'angular.svg', 11.50),
(4, '004', 'Lesson 4', 'Angular lesson 4', 'angular.svg', 9.30);

Database connection and configuration for our store.

Make a new configuration.php file and add '< ? php' on top and close '? >' the page.
Add the code below between the open and close of this page.

We also integrate our paypal sandbox credentials. You can get a test account here after registration:Paypal


The Buyer email is where you can spend virtual money, the Facilitator email
is the account that will receive the payments.
You can find your API PASSWORD and API SIGNATURE Credentials when you click the profile link.

$currency = '$'; //Currency Character or code

$db_username 	= 'root';
$db_password 	= '';
$db_name 		= 'webshop';
$db_host 		= 'localhost';

//paypal settings
$PayPalMode 			= 'sandbox'; // sandbox or live
$PayPalApiUsername 		= ''; //PayPal API Username = Your Paypal Email
$PayPalApiPassword 		= 'Q66NY3G5K3M4KTGJ'; //Paypal API password
$PayPalApiSignature 	= 'AFcWxV21C7fd0v3bYYYRCpSSRl31ANXNRnBxappj6P-KkmGiaMglNgmK'; //Paypal API Signature
$PayPalCurrencyCode 	= 'USD'; //Paypal Currency Code
$PayPalReturnURL 		= ''; //Point to paypal-express-checkout page
$PayPalCancelURL 		= ''; //Cancel URL if user clicks cancel

//Additional taxes and fees											
$HandalingCost 		= 0.00;  //Handling cost for the order.
$InsuranceCost 		= 0.00;  //shipping insurance cost for the order.
$shipping_cost      = 1.20; //shipping cost
$ShippinDiscount 	= 0.00; //Shipping discount for this order. Specify this as negative number (eg -1.00)
$taxes              = array( //List your Taxes percent here.
                            'VAT' => 21, 
                            'Service Tax' => 5

//connection to MySql						
$mysqli = new mysqli($db_host, $db_username, $db_password,$db_name);						
if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);

Frontpage for our store.

Download all files in this ZIP Dowload.
We need:
in our root folder.
In the zip file you will find the complete structure
including the files.
Learn from the files and build something on your own.

php angular shop shopping cart basket buy shopping cart


Once you connected the database to your website you should see the products that we added in the database.
You can implement more and other products.
Please support the hard work and share my efforts.