ok
Direktori : /proc/thread-self/root/home2/selectio/public_html/thecomponents.in/ |
Current File : //proc/thread-self/root/home2/selectio/public_html/thecomponents.in/checkout.php |
<?php include "header2.php"; error_log($_SESSION['caliber']['id']); $query = $pdo->prepare("SELECT cart.id as cart_id,cart.user_id,cart.qty,cart.product_id,products.name as product_name, users.name,products.image,product_variant.stock,product_variant.price FROM cart LEFT JOIN products ON cart.product_id=products.id LEFT JOIN users ON users.id=cart.user_id LEFT JOIN product_variant ON product_variant.product_id = cart.product_id WHERE cart.user_id=".$_SESSION['caliber']['id']); $query->execute(); $cart = $query->fetchAll(PDO::FETCH_ASSOC); $user_query = $pdo->prepare("SELECT * FROM users WHERE id=".$_SESSION['caliber']['id']); $user_query->execute(); $user_result = $user_query->fetchAll(PDO::FETCH_ASSOC); ?> <main class="main checkout"> <div class="page-content pt-7 pb-10 mb-10"> <div class="step-by pr-4 pl-4"> <h3 class="title title-simple title-step"> <a href="cart.php">1. Shopping Cart</a> </h3> <h3 class="title title-simple title-step active"> <a href="checkout.php">2. Checkout</a> </h3> <h3 class="title title-simple title-step"> <a href="order.php">3. Order Complete</a> </h3> </div> <div class="container mt-7"> <form action="#" class="form" method="post" id="checkout"> <div class="row"> <div class="col-lg-7 mb-6 mb-lg-0 pr-lg-4"> <h3 class="title title-simple text-left text-uppercase">Billing Details</h3> <div class="row"> <div class="col-xs-6"> <label>First Name *</label> <input type="text" class="form-control" value="<?=$user_result[0]['name']?>" name="firstname" required=""> </div> <div class="col-xs-6"> <label>Email Address *</label> <input type="text" class="form-control form-control-md" value="<?=$user_result[0]['email']?>" name="lastname" required=""> </div> <div class="col-xs-6"> <label>Phone *</label> <input type="tel" class="form-control form-control-md" value="<?=$user_result[0]['mobile']?>" name="mobile_no" required> </div> <div class="col-xs-6"> <label>Alternate No *</label> <input type="tel" class="form-control form-control-md" value="<?=$user_result[0]['latitude']?>" name="alternate_no"> </div> </div> <label>Street Address *</label> <input type="text" placeholder="House number and street name" value="<?=$user_result[0]['area']?>" class="form-control form-control-md mb-2" name="address" required=""> <label>Delivery Address *</label> <input type="text" placeholder="House number and street name" value="<?=$user_result[0]['longitude']?>" class="form-control form-control-md mb-2" name="delivery_address" required=""> <div class="row"> <div class="col-xs-6"> <label>Town / City *</label> <input type="text" value="<?=$user_result[0]['city']?>" class="form-control form-control-md" name="town" required=""> </div> <!--<div class="col-xs-6"> <label>Country*</label> <input type="text" class="form-control form-control-md" value="" name="country" required=""> </div>--> <div class="col-xs-6"> <label>ZIP *</label> <input type="text" value="<?=$user_result[0]['pincode']?>" class="form-control form-control-md" name="zip" required=""> </div> </div> <div class="row"> </div> </div> <aside class="col-lg-5 sticky-sidebar-wrapper"> <div class="sticky-sidebar mt-1" data-sticky-options="{'bottom': 50}"> <div class="summary pt-5"> <h3 class="title title-simple text-left text-uppercase">Your Order</h3> <table class="order-table"> <thead> <tr> <th>Product</th> <th></th> </tr> </thead> <?php $total_price="0"; foreach($cart as $cart_total){ $total_price+= number_format($cart_total['qty'])*number_format($cart_total['price']); $total_amount = $cart_total['qty']*$cart_total['price']; ?> <input name="product_id[]" type="hidden" value="<?=$cart_total['product_id']?>"> <input name="product_name[]" type="hidden" value="<?=$cart_total['name']?>"> <input name="product_qty[]" type="hidden" value="<?=$cart_total['qty']?>"> <input name="product_sub_total[]" type="hidden" value="<?=$total_amount?>"> <input name="product_price[]" type="hidden" value="<?=$cart_total['price']?>"> <tbody> <tr> <td class="product-name"><?=$cart_total['name']?> <span class="product-quantity">×<?=$cart_total['qty']?></span> </td> <td class="text-body"> <i class="bi bi-currency-rupee"></i> ₹<?= $total_amount ?> </td> </tr> <?php } ?> <tr class=""> <td> <h4 class="summary-subtitle">Subtotal</h4> </td> <td class="summary-subtotal-price pb-0 pt-0"> <i class="bi bi-currency-rupee"></i> <span class=""> ₹ <?= $total_price ?> </span> </td> </tr> <tr class=""> <td class="pb-0"> <h4 class="summary-subtitle">Total</h4> </td> <td class=" pt-0 pb-0"> <i class="bi bi-currency-rupee"></i> <span class="one_product_price"> ₹<?= $total_price ?> </span> </td> </tr> </tbody> </table> <div class="payment accordion radio-type"> <h4 class="summary-subtitle ls-m pb-3">Payment Methods</h4> <div class="card"> <div class="card-header"> <a href="#collapse2" class="expand text-body text-normal ls-m">Cash on delivery</a> </div> <div id="collapse2" class="collapsed"> <div class="card-body ls-m"> Pay with cash upon delivery. </div> </div> </div> </div> <input type="hidden" name="total_amount_price" value="<?=$total_price?>"> <div class="form-checkbox mt-4 mb-5"> <input type="checkbox" class="custom-checkbox" id="terms-condition" name="type_payment"/> <label class="form-control-label" for="terms-condition"> I have read and agree to the website <a href="#">terms and conditions </a>* </label> </div> <button type="submit" class="btn btn-dark btn-rounded btn-order">Place Order</button> </div> </div> </aside> </div> </form> </div> </div> </main> <?php include "footer.php"; ?> <script> $('#checkout').on('submit', function(e){ console.log("Click And Form Working"); e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); var formData = new FormData(this); formData.append('type', 'checkout_order'); $.ajax({ url: 'api/checkout-api.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ alert(response['message']); window.location.href="order-complete.php?id="+response['order_id']; $("#checkout").trigger("reset"); $('#loading-div').hide(); $('#content-div').show(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); } } }); }); $(document).ready(function(){ grand_total(); $("body").on("click",".plus",function(){ console.log("clicked"); var qty=Number($(this).closest("tr").find(".total_product_price").val()); var price=Number($(this).closest("tr").find(".one_product_price").text()); console.log(qty); console.log(price); $(this).closest("tr").find(".product_total").text(price*qty); grand_total(); }); }); function grand_total(){ var tot=0; $(".one_product_price").each(function(){ tot+=Number($(this).text()); }); var inpt = '<input type="hidden" name="total_amount" value="'+tot+'">'; $("#total_amount_input").append(inpt); $(".total_product_price").text(tot); } </script>