how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php
how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php how to order placed ecoomerce website in php
<?php
require_once 'db_connect.php';
@session_start();
require_once 'Cart.class.php';
$cart = new Cart;
$total_amount=$cart->total();
date_default_timezone_set('Asia/Kolkata');
$from_date = date( 'd-m-Y h:i A', time () );
$from_date1=date('d-m-Y');
$disssccont=number_format(@$_SESSION['discount_amount'],2);
$totasubbb=number_format(@$_SESSION['sub_newtotal'],2);
$full_name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$full_address=$_POST['full_address'];
$zip=$_POST['zip'];
$City=$_POST['City'];
$payment_type=$_POST['payment_type'];
$grand_amount=number_format($_POST['grand_amount'],2);
if(!empty($_SESSION['discount_amount']) && !empty($_SESSION['sub_newtotal'])){
$grand_amounttt=$_SESSION['sub_newtotal'];
$discountt=$_SESSION['discount_amount'];
$coupon_code=$_SESSION['login_promo'];
echo $sqlww="INSERT INTO tbl_order(full_name,email,mobile,full_address,city,zip_code,payment_type,total_amount,order_status,from_date,order_time,discount,coupon_code)VALUES('$full_name','$email','$mobile','$full_address','$City','$zip','$payment_type','$grand_amounttt','1','$from_date1','$from_date','$discountt','$coupon_code')";
}else{
echo $sqlww="INSERT INTO tbl_order(full_name,email,mobile,full_address,city,zip_code,payment_type,total_amount,order_status,from_date,order_time)VALUES('$full_name','$email','$mobile','$full_address','$City','$zip','$payment_type','$total_amount','1','$from_date1','$from_date')";
}
// die;
$runn=mysqli_query($conn,$sqlww);
$lastid=mysqli_insert_id($conn);
$ord="70000800";
$orderid=$ord.$lastid;
$inv="BAEVELA900";
$invoiceid=$inv.$lastid;
$updateqq="UPDATE tbl_order SET order_id='$orderid',invoice_id='$invoiceid' WHERE id='$lastid'";
$rubnn=mysqli_query($conn,$updateqq);
$cartItems = $cart->contents();
// Prepare SQL to insert order items
$sql = '';
foreach($cartItems as $item){
$sql .= "INSERT INTO order_items (order_id, product_id, quantity,price) VALUES ('".$orderid."', '".$item['id']."', '".$item['qty']."','".$item['price']."');";
}
// Insert order items in the database
$insertOrderItems = $db->multi_query($sql);
if($insertOrderItems){
// Remove all items from cart
$cart->destroy();
/* echo '<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success!</strong> Your order has been successfully placed. <strong>Order Id-'.$orderid.' </strong>
</div>';*/
$_SESSION['orderrrr_id']=$orderid;
// Redirect to the status page
//$redirectLoc = 'orderSuccess.php?id='.$orderID;
}
$ppp ="<th span style='background-color:darkred;color:white;text-align: center;' colspan='2'>Price Details</th>";
//$oid=$OrderId.$lastid;
$queryyyw="SELECT*FROM order_items WHERE order_id='$orderid'";
$rusj=mysqli_query($con,$queryyyw);
while($fetch_dataaa=mysqli_fetch_array($rusj)){
$product_id=$fetch_dataaa['product_id'];
$queryyy="SELECT*FROM product_master WHERE id='$product_id'";
$runnnn=mysqli_query($con,$queryyy);
$fetch_data=mysqli_fetch_array($runnnn);
$name=$fetch_data['productName'];
$pricee=$fetch_dataaa['price'];
$quantity=$fetch_dataaa['quantity'];
$dashh="X";
$ppp .="
<tr>
<td>".$name."</td>
<td>₹".number_format($pricee,2).$dashh.$quantity."</td>
</tr>";
}
if(!empty($_SESSION['discount_amount']) && !empty($_SESSION['sub_newtotal'])){
$diss="
<tr>
<th>Total Amount</th>
<th>₹$grand_amount</th>
</tr>
<tr>
<th>Discount Amount</th>
<th>-₹$disssccont</th>
</tr>
<tr>
<th>Grand Amount</th>
<th>₹$totasubbb</th>
</tr>";
}else{
$diss="
<tr>
<th>Total Amount</th>
<th>₹$grand_amount</th>
</tr>";
}
$to = $email;
$subject = 'Baevella Product New Order!';
$message="<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 96%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<img src='https://www.baevella.com/logo.jpg' >
<p>Dear <b style='color:#ea670c;'>$full_name</p></b>
<p>Thank You For Purchasing Baevella Product. Someone will call and visit shortly. Your patience is
highly appreciated.
</P>
<table id='customers'>
<tr>
<th colspan='2'>Order Summary</th>
</tr>
<tr>
<td>Order Id</td>
<td>$orderid</td>
</tr>
<tr>
<td>Invoice Id</td>
<td>$invoiceid</td>
</tr>
<tr>
<td>Name</td>
<td>$full_name</td>
</tr>
<tr>
<td>Email</td>
<td>$email</td>
</tr>
<tr>
<td>Mobile</td>
<td>$mobile</td>
</tr>
<tr>
<td>Address</td>
<td>$full_address</td>
</tr>
<tr>
<td>Zip Code</td>
<td>$zip</td>
</tr>
$ppp
<tr>
<td>Payment Type</td>
<td>Cash</td>
</tr>
<tr>
<td>Order Date</td>
<td>$from_date1</td>
</tr>
$diss
</table>
</body>
</html>";
//echo $message;die;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$headers .= "From: info@baevella.com\r\n";
$headers .= 'From: BAEVELLA <info@baevella.com>' . "\r\n";
//$headers .= 'cc:ravindrayadav170@yahoo.com\r\n';
//$headers .= "Bcc: users170@gmail.com\r\n";
$headers .= 'Cc: users1328@gmail.com' . "\r\n";
$headers .= 'Bcc: users54030@gmail.com' . "\r\n";
mail($to, $subject, $message, $headers);
//echo $email = $row['c_email'];
echo "<script type='text/javascript'> document.location = 'order-success.php'; </script>";
?>
<!-- START SECTION BREADCRUMB -->
<div class="breadcrumb_section bg_gray page-title-mini">
<div class="container"><!-- STRART CONTAINER -->
<div class="row align-items-center">
<div class="col-md-6">
<div class="page-title">
<h1>Place Order </h1>
</div>
</div>
</div>
</div><!-- END CONTAINER-->
</div>
<!-- END SECTION BREADCRUMB -->
<?php
if(isset($_GET['cart_delete'])){
$q = mysqli_query($con,"delete from cart_master where id='$_GET[cart_delete]'");
if($q){
echo "<script>location.href='cart.php';</script>";
}
} ?>
<!-- START MAIN CONTENT -->
<div class="main_content">
<?php
//$userIP = $_SERVER['REMOTE_ADDR'];
// $product_get = mysqli_query($con,"select * from cart_master where ip = '$userIP'");
?>
<!-- START SECTION SHOP -->
<div class="section">
</div>
<!-- END SECTION SHOP -->
<!-- START SECTION SUBSCRIBE NEWSLETTER -->
<div class="section bg_default small_pt small_pb">
<div class="container">
<div class="row align-items-center">
<div class="col-md-6">
<div class="heading_s1 mb-md-0 heading_light">
<h3>Subscribe Our Newsletter</h3>
</div>
</div>
<div class="col-md-6">
<div class="newsletter_form">
<form>
<input type="text" required="" class="form-control rounded-0" placeholder="Enter Email Address">
<button type="submit" class="btn btn-dark rounded-0" name="submit" value="Submit">Subscribe</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- START SECTION SUBSCRIBE NEWSLETTER -->
</div>
<!-- END MAIN CONTENT -->
<script>
function updateCartItem(id){
var qty=$("#hhddhdh"+id).val();
$.get("cartAction.php", {action:"updateCartItem", id:id, qty:qty}, function(data){
window.location.reload();
if(data == 'ok'){
location.reload();
}else{
// alert('Cart update failed, please try again.');
}
});
}
</script>
<script>
function updateCart(id)
{
$.ajax({
url:updqty.php,
type:'POST',
data:$("#frm"+id).serialize(),
success:function(res){
}
});
}
</script>
<?php
include ('include/footer.php');
?>
////////////////////////////// table ////////////////////////////////////////
-- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 09, 2022 at 08:58 PM
-- Server version: 10.4.19-MariaDB
-- PHP Version: 7.3.28
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `hr_ecommerce`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_order`
--
CREATE TABLE `tbl_order` (
`id` int(11) NOT NULL,
`order_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`invoice_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`full_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`mobile` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`full_address` text COLLATE utf8_unicode_ci NOT NULL,
`city` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`zip_code` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`total_amount` int(11) NOT NULL,
`discount` int(11) NOT NULL,
`coupon_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`payment_type` int(11) NOT NULL,
`razorpay_payment_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`from_date` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`order_time` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`order_status` int(11) NOT NULL,
`order_complete_date` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`update_data` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `tbl_order`
--
INSERT INTO `tbl_order` (`id`, `order_id`, `invoice_id`, `full_name`, `email`, `mobile`, `full_address`, `city`, `zip_code`, `total_amount`, `discount`, `coupon_code`, `payment_type`, `razorpay_payment_id`, `from_date`, `order_time`, `order_status`, `order_complete_date`, `update_data`) VALUES
(1, '', '', 'Ravindra Yadav', 'ravindrayadav170@yahoo.com', '6299812434', 'New Delhi', 'Delhi', '110046', 7693, 0, NULL, 1, NULL, '08-06-2022', '08-06-2022 11:02 PM', 1, '', '2022-06-08 17:34:38'),
(2, '700008002', 'BAEVELA9002', 'Ravindra Yadav', 'ravindrayadav170@yahoo.com', '6299812434', 'New Delhi', 'Delhi', '110046', 7693, 0, NULL, 1, NULL, '08-06-2022', '08-06-2022 11:05 PM', 1, '', '2022-06-08 17:35:51');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_order`
--
ALTER TABLE `tbl_order`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_order`
--
ALTER TABLE `tbl_order`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Comments
Post a Comment