<!-- Header Wrap Starts -->
<?php include "common/header.php"; ?> 

<!-- Header Wrap Ends -->

<?php include "common/navbar.php"; ?> 

<style type="text/css">
  th,td {
   text-align:center;
 }

</style>

<!-- Main Container Starts -->
<div class="main-container" >
  <!-- Product Container Starts -->
  <div id="product-product" class="container" style="background-image: url(image/bg.jpg); ">
    <!-- Row Starts -->  
    <div class="row col-lg-12">

      <!-- Content Area Starts -->
      <div id="content" class="col-lg-12 login" style="padding: 15px;">

       <h3 class="page-heading-1">MY CART</h3>


       <div class="col-lg-12 col-md-12">
        <div class="table-content wnro__table table-responsive" id="shop_tbl"></div>
      </div>

      <div class="col-lg-6 mb-3">
        <div class="pull-left"><a href="index.php" class="btn btn-inverse"><i class="fa fa-arrow-left"></i> CONTINUE SHOPPING</a></div>
      </div>
      <div class="col-lg-6 price-total" style="display:none">
        <table width="100%" class="table table-bordered tot-table">
          <tr><td width="50%" style="text-align: left; padding-left: 2%"><h6 class="m-0">Sub Total</h6></td><td><h6 class="m-0 text-right">LKR <span id="sub_tot">0</span></h6></td></tr>
          <tr><td style="text-align: left; padding-left: 2%"><h6 class="m-0">Delivery Charges</h6></td><td><h6 class="m-0 text-right">LKR <span id="del_amount">0</span></h6></td></tr>
          <tr><td style="text-align: left; padding-left: 2%"><h5 class="text-primary text-uppercase m-0">Grand Total</h5></td><td><h5 class="text-primary text-uppercase m-0 text-right">LKR <span id="g_tot">0</span></h5><input type="hidden" id="net_amount" readonly></td></tr>
        </table>

        <div class="mt-5 product-add-to-cart chkt text-center">
          <div class="buttons clearfix">
            <div class="pull-right"><a href="javascript:void(0);" id="btn_checkout" class="btn btn-inverse">PROCEED TO CHECKOUT</a></div>
          </div>
        </div>

      </div>


    </div>

  </div>
  <!-- Content Area Ends -->    

</div>
<!-- Row Ends -->  
</div>
<!-- Product Container Ends -->

</div>
<!-- Main Container Ends -->
<!-- Footer Starts -->
<?php include "common/footer.php"; ?> 

<!-- Footer Ends -->
<script type="text/javascript">

  $(document).ready(function () {
    load_cart_table();
    get_delivery_fee();
  });

  $("#btn_checkout").click(function() {
    window.location.href = 'checkout';
  });

  function get_delivery_fee() {
    $("#pre_loader").fadeIn();
    $.post( "connection/my_cart_conn", {'get_delivery_fee': "data"}, function( data ) {
      if(data.msgType === 1) {
        var del_fee = parseFloat(data.del_fee).toFixed(2);
        $('#del_amount').text(del_fee);

        setTimeout(function() {
          var tot = $('#net_amount').val();
          var g_tot = parseFloat(del_fee) + parseFloat(tot);
          $('#g_tot').text(parseFloat(g_tot).toFixed(2));
          $("#pre_loader").fadeOut();
        }, 500);

      } else {
        setTimeout(function() {
          $('#del_amount').text(parseFloat(0).toFixed(2));
          $('#g_tot').text(parseFloat($('#net_amount').val()).toFixed(2));
          $("#pre_loader").fadeOut();
        }, 500);
      }
    }, "json");
  }
</script>

</body>
</html> 
