ok
Direktori : /home2/selectio/public_html/ramali.in/ |
Current File : /home2/selectio/public_html/ramali.in/checkout.php |
<?php include "header.php"; //$_SESSION['ramali_textiles']['id']; error_log("SELECT cart.*,products.image,products.name,product_variant.price,product_variant.measurement,product_variant.stock FROM `cart` LEFT JOIN products ON products.id=cart.product_id LEFT JOIN product_variant ON product_variant.id=cart.product_variant_id WHERE user_id=".$_SESSION['ramali_textiles']['id']); $query = $pdo->prepare("SELECT cart.*,products.image,products.name,product_variant.price,product_variant.measurement,product_variant.weight,product_variant.stock FROM `cart` LEFT JOIN products ON products.id=cart.product_id LEFT JOIN product_variant ON product_variant.id=cart.product_variant_id LEFT JOIN taxes ON taxes.id=products.tax_id WHERE cart.user_id=".$_SESSION['ramali_textiles']['id']); $query->execute(); $cart = $query->fetchAll(PDO::FETCH_ASSOC); error_log("SELECT * FROM users WHERE id=".$_SESSION['ramali_textiles']['id']); $user_query = $pdo->prepare("SELECT * FROM users WHERE id=".$_SESSION['ramali_textiles']['id']); $user_query->execute(); $user_result = $user_query->fetchAll(PDO::FETCH_ASSOC); ?> <style> .header-bottom:not(.fixed) .show-dropdown .dropdown-box { margin-top: 2.2rem; display: none; } h3.title.billing-title.text-uppercase.ls-10.pt-1.pb-3.mb-0 { padding-top: 0px !important; } select.form-control.form-control-md { margin: 0px !important; max-width: unset !important; } table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } th, td { border: 1px solid #ffffff; text-align: left; padding-top: 4%; /*border-bottom:1px solid #ccc;*/ } .payment-methods { padding-top: 15px; } .row.gutter-sm.ret { padding-top: 15px; } .card-header { line-height: 26px; } .bor { box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; padding: 15px; } th.prorange { padding-top: 0px; } .form-group.place-order.pt-6 { padding-top: 10px !important; } .order-summary-wrapper.sticky-sidebar { width: 100% !important; } /*.row.gutter-sm.ret {*/ /* padding-top: 22px;*/ /*}*/ @media (min-width: 340px) and (max-width: 479px) { ul.breadcrumb.shop-breadcrumb.bb-no { margin: 0px; padding-top: 15px; padding-bottom: 25px; } ul.breadcrumb.shop-breadcrumb.bb-no li { font-size: 25px !important; } .row.gutter-sm.ret { padding-top: 0px; } .form .form-control { margin-bottom: 1rem; } select.form-control.form-control-md { margin-bottom: 10px !important; } .form-group.place-order.pt-6 { padding-top: 15px !important; } button.btn.btn-dark.btn-block.btn-rounded { /*width: 50%;*/ /*margin-left: 10%;*/ } table.order-table { width: auto !important; } button.btn.btn-dark.btn-block.btn-rounded { width: 50%; /* margin-left: 10%; */ } /*td.product-name {*/ /*width: 50%;*/ /*}*/ } h3.title.text-uppercase.ls-10 { justify-content: center; } </style> <main class="main checkout"> <!-- Start of Breadcrumb --> <nav class="breadcrumb-nav"> <div class="container"> <ul class="breadcrumb shop-breadcrumb bb-no"> <li class="active" style="font-size: 35px;margin-bottom: -2%;"> Checkout </li> </ul> </div> </nav> <!-- End of Breadcrumb --> <!-- Start of PageContent --> <div class="page-content" id="content-div"> <div class="container"> <!--<div class="coupon-content mb-4">--> <!-- <p>If you have a coupon code, please apply it below.</p>--> <!-- <div class="input-wrapper-inline">--> <!-- <input type="text" name="coupon_code" class="form-control form-control-md mr-1 mb-2" placeholder="Coupon code" id="coupon_code">--> <!-- <button type="submit" class="btn button btn-rounded btn-coupon mb-2" name="apply_coupon" value="Apply coupon">Apply Coupon</button>--> <!-- </div>--> <!--</div>--> <form class="form checkout-form" action="#" method="post" id="checkout"> <div class="row mb-9"> <div class="col-lg-7 pr-lg-4 mb-4"> <h3 class="title billing-title text-uppercase ls-10 pt-1 pb-3 mb-0"> Billing Details </h3> <div class="row gutter-sm"> <div class="col-xs-6"> <div class="form-group"> <label>Name *</label> <input type="text" class="form-control form-control-md" value="<?=$user_result[0]['name']?>" name="firstname" required=""> </div> </div> <div class="col-xs-6"> <div class="form-group"> <label>Email *</label> <input type="text" class="form-control form-control-md" value="<?=$_SESSION['ramali_textiles']['email']?>" name="lastname" required=""> </div> </div> <div class="col-xs-6"> <div class="form-group"> <label>Mobile Number</label> <input type="text" class="form-control form-control-md" value="<?=$_SESSION['ramali_textiles']['mobile']?>" name="mobile_no"> </div> </div> <div class="col-xs-6"> <div class="form-group"> <label>Alternate Mobile Number *</label> <input type="text" placeholder="Alternate Number" value="" class="form-control form-control-md mb-2" name="alternate_mobile_no"> </div> </div> </div> <div class="form-group"> <label>Address *</label> <input type="text" placeholder="House number and street name" value="<?=$_SESSION['ramali_textiles']['area']?>" class="form-control form-control-md mb-2" name="address" required=""> </div> <div class="row gutter-sm"> <div class="col-md-4"> <div class="form-group"> <label>City *</label> <input type="text" value="<?=$_SESSION['ramali_textiles']['city']?>" class="form-control form-control-md" name="town" required=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>Pincode *</label> <input type="text" value="<?=$_SESSION['ramali_textiles']['pincode']?>" class="form-control form-control-md" name="zip" required=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>Country *</label> <input type="text" class="form-control form-control-md" name="country" required=""> </div> </div> </div> <div class="row gutter-sm ret"> <div class="col-md-6"> <div class="form-group"> <label>Select State*</label> <div class="select-box"> <select name="state" onchange="select_district()" id="state_id" class="form-control form-control-md" required> <option></option> <?php $shipping = $pdo->prepare("SELECT * FROM tb_state WHERE status=1"); $shipping->execute(); $shipping_result = $shipping->fetchAll(PDO::FETCH_ASSOC); $shipping_count = $shipping->rowCount(); foreach($shipping_result as $shipping_data){ echo '<option value="'.$shipping_data['id'].'" >'.$shipping_data['state'].'</option>'; } ?> </select> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label>Select District*</label> <div class="select-box"> <select name="state" class="form-control form-control-md" onchange="select_amount()" id="shipping_amount" required> <option> First Select State</option> </select> </div> </div> </div> </div> </div> <div class="col-lg-5 mb-4 sticky-sidebar-wrapper"> <div class="pin-wrapper" style="height: 898.969px;"><div class="order-summary-wrapper sticky-sidebar" style="border-bottom: 1px solid rgb(238, 238, 238); width: 505px;"> <h3 class="title text-uppercase ls-10" style="color: #fe7c00;">Your Order</h3> <div class="order-summary bor"> <!--<div class="bor">--> <table class="order-table"> <thead> <tr> <th colspan="2" class="prorange"> <b>Product</b> </th> </tr> </thead> <?php foreach($cart as $cart_total){ $total_amount = $cart_total['stock']*$cart_total['price']; ?> <input name="product_id[]" type="text" value="<?=$cart_total['product_id']?>"> <input name="product_name[]" type="text" value="<?=$cart_total['name']?>"> <input name="product_qty[]" type="text" value="<?=$cart_total['stock']?>"> <input name="product_qty[]" type="text" value="<?=$cart_total['stock']?>"> <input name="product_sub_total[]" type="text" value="<?=$total_amount?>"> <input name="product_price[]" type="text" value="<?=$cart_total['price']?>"> <input name="weight[]" type="texxt" id="weight_per" value="<?=$cart_total['weight']?>"> <tbody> <tr class="bb-no"> <td class="product-name"> <?=$cart_total['name']?> </td> <td class="product-total"> <span class="one_product_price"> <i class="bi bi-currency-rupee"></i> <?php echo $cart_total['price'] ?> </span> </td> </tr> <?php } ?> </tr> <td class="product-name"> <span class="product-quantity"> Shipping Weight Amount</span> </td> <td class="product-total"> <span id="shipping_charge"></span> </td> </tr> </tbody> <tfoot> <tr class="order-total"> <th> <b>Total</b> </th> <td> <i class="bi bi-currency-rupee"></i> <span class="total_product_price"></span> </td> </tr> </tfoot> <span id="total_amount_input"></span> </table> <!--</div>--> <div class="payment-methods" id="payment_method"> <h4 class="title font-weight-bold ls-25 pb-0 mb-1">Payment Methods</h4> <div class="accordion payment-accordion"> <div class="card"> <div class="card-header"> <input type="radio" name="type_payment" value="Online Paytment" required> <label>Online Payment</label> </div> </div> <div class="card"> <div class="card-header"> <input type="hidden" name="pending" value="Pending"> <input type="Hidden" name="type_payment" value="COD Paytment"> <!--<label>Cash On Delivery</label>--> </div> </div> </div> </div> <div class="form-group place-order pt-6"> <button type="submit" class="btn btn-dark btn-block btn-rounded"> Place Order </button> </div> </div> </div></div> </div> </div> </form> </div> </div> <div id="loading-div"> <img src="images/loading.gif" alt=""> </div> <!-- End of PageContent --> </main> <?php include "footer.php"?> <style> .pin-wrapper { height: auto !important; } #scroll-top.show { opacity: 1; bottom: 40px; } </style> <script> $(document).ready(function(){ $('#loading-div').hide(); $('#content-div').show(); }); function select_district(){ var id = $("#state_id").val(); $.ajax({ url: 'ui-api/api-cart.php', type: 'post', dataType: 'json', data :{id:id,type:'state_select'}, success: function (response) { console.log(response['district']); $('#shipping_amount').html(response['district']); select_amount(); } }); } function select_amount(){ var id = $("#shipping_amount").val(); var per_weight = $("#weight_per").val(); alert(per_weight); $.ajax({ url: 'ui-api/api-cart.php', type: 'post', dataType: 'json', data :{id:id,type:'shipping_amount',per_weight:per_weight}, success: function (response) { $('#shipping_charge').text(response['shipping']); grand_total(); } }); } $('#checkout').on('submit', function(e){ console.log("Click And Form Working"); e.preventDefault(); $('#loading-div').hide(); $('#content-div').show(); var formData = new FormData(this); formData.append('type', 'checkout_order'); $.ajax({ url: 'api/checkout.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ window.location.href="payment-redirect.php?amount="+response['amount']+"&order_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; var shipping = Number($("#shipping_charge").text()); $(".one_product_price").each(function(){ tot+=Number($(this).text()); }); var grand_total = tot+shipping; var inpt = '<input type="hidden" name="total_amount" value="'+grand_total+'">'; $("#total_amount_input").append(inpt); $(".total_product_price").text(grand_total); } </script>