E-commerce PHP is an e-commerce application developed using the native PHP programming language. Some of the technology stacks used in this application are:
- Programming language: PHP
- Databases: MySQL
- Local web server: XAMPP (includes php, mysql, and apache)
- IDE: Visual Studio Code
- Visual Database Management: phpMyAdmin or Heidi SQL
- Login Access: username: [email protected] pass: 1234567, username: [email protected], pass: 1234567, username: [email protected] pass: 1234567
- Login
- Register
- Display Account
- Change Password
- Product List
- Product Details
- Shopping Cart
- Checkout
- Payment Using Paypal
- Pagination
- Admin Dashboard
- Clone this project and save it in C:\xampp\htdocs\
- Create database in your local DBMS using phpMydmin or Heidi SQL or can also be done through the command prompt by typing the command: mysql > create database ecommerce_app;
- Import the ecommerce.sql database containing the DDL of tables and data into your DBMS (ecommerce_app)
- Open the application using Visual Studio Code, and configure the database in the file /server/connection.php ($host = "localhost", $user = "root", $password = "", $database = "ecommerce")
<?php
$conn = mysqli_connect("localhost", "root", "", "ecommerce")
or die("Can't connect to the database");
?>
- Create a Dummy Paypal Accout to Payment Test
- Choose a Business Account
- After the business account is created, go to the url: https://developer.paypal.com/home
- Paypal Developer Dashboard
- Create App and Credentials
- Create Dummy Account for Buyer and and Seller, which Business for Seller Account and Personal for Buyer Account
- Integrate Paypal to your Application
<div id="paypal-button-container"></div>
<!-- Replace "test" with your own sandbox Business account app client ID -->
<script src="https://www.paypal.com/sdk/js?client-id=AZc7gISngCVfWIqTNzlMZRSCsd7cte4sTB4ZrK7JEJHUGO9CEALMKj4mzo5ZIe2i6DRAiOhJouUWqxXF¤cy=USD"></script>
<script>
paypal.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [{
amount: {
value: '<?php echo $amount; ?>' // Can also reference a variable or function
}
}]
});
},
// Finalize the transaction after payer approval
onApprove: (data, actions) => {
return actions.order.capture().then(function(orderData) {
// Successful capture! For dev/demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
const transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction ' + transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
window.location.href = "server/complete_payment.php?transaction_id="+transaction.id+"&order_id="+<?php echo $order_id; ?>;
// When ready to go live, remove the alert and show a success message within this page. For example:
// const element = document.getElementById('paypal-button-container');
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
}
}).render('#paypal-button-container');
</script>