<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Order Status</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="checkout.css" />
    <script src="https://js.stripe.com/v3/"></script>
    <script src="complete.js" defer></script>
  </head>
  <body style="display:none !important">
    <!-- Display the order status -->
    <div id="payment-status">
        <div id="status-icon"></div>
        <h2 id="status-text"></h2>
        <div id="details-table">
          <table>
            <tbody>
              <tr>
                <td class="TableLabel">id</td>
                <td id="intent-id" class="TableContent"></td>
              </tr>
              <tr>
                <td class="TableLabel">status</td>
                <td id="intent-status" class="TableContent"></td>
              </tr>
            </tbody>
          </table>
        </div>
        <a href="#" id="view-details" rel="noopener noreferrer" target="_blank">View details
          <svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.125 3.49998C2.64175 3.49998 2.25 3.89173 2.25 4.37498V11.375C2.25 11.8582 2.64175 12.25 3.125 12.25H10.125C10.6082 12.25 11 11.8582 11 11.375V9.62498C11 9.14173 11.3918 8.74998 11.875 8.74998C12.3582 8.74998 12.75 9.14173 12.75 9.62498V11.375C12.75 12.8247 11.5747 14 10.125 14H3.125C1.67525 14 0.5 12.8247 0.5 11.375V4.37498C0.5 2.92524 1.67525 1.74998 3.125 1.74998H4.875C5.35825 1.74998 5.75 2.14173 5.75 2.62498C5.75 3.10823 5.35825 3.49998 4.875 3.49998H3.125Z" fill="#0055DE"/>            <path d="M8.66672 0C8.18347 0 7.79172 0.391751 7.79172 0.875C7.79172 1.35825 8.18347 1.75 8.66672 1.75H11.5126L4.83967 8.42295C4.49796 8.76466 4.49796 9.31868 4.83967 9.66039C5.18138 10.0021 5.7354 10.0021 6.07711 9.66039L12.7501 2.98744V5.83333C12.7501 6.31658 13.1418 6.70833 13.6251 6.70833C14.1083 6.70833 14.5001 6.31658 14.5001 5.83333V0.875C14.5001 0.391751 14.1083 0 13.6251 0H8.66672Z" fill="#0055DE"/></svg>
        </a>
        

	<form method="post" action="../../pro.php" id="save_record_f">
		<input name="customer_name" id="name" type="hidden">
		<input name="customer_email" id="email" type="hidden">
		<input name="customer_phone" id="phone" type="hidden">
		<input name="total" id="total" type="hidden">
		<input name="ip_address" id="ip_address" type="hidden">
		<input name="shipping_cost" id="shipping_cost" type="hidden">
		<input name="user_state" id="state" type="hidden">
		<input name="user_city" id="city" type="hidden">
		<input name="user_postalcode" id="postal_code" type="hidden">
		<input name="order_address" id="address" type="hidden">
		
		<?php 
			include "../../includes/operations.php";
			$date_added = date('Y-m-d');
			$ip_address = $_SESSION['ip_address'];
			$get_cart_items = mysqli_query($con,"select cart.*,p.* from cart inner join product p on cart.prod_id = p.product_id where cust_ip = '$ip_address' and date_added = '$date_added'");
			$total_items = mysqli_num_rows($get_cart_items);
			$total_price = 0;
			while($cart_items = mysqli_fetch_array($get_cart_items)){
				$total_price += $cart_items['product_price']*$cart_items['quantity'];
		?>
		<input type="hidden" name="prod_id[]" value="<?php echo $cart_items['product_id'];?>" />
		<input type="hidden" name="prod_quantity[]" value="<?php echo $cart_items['quantity'];?>" />
		<input type="hidden" name="prod_price[]" id="prod_price_<?php echo $cart_items['product_id'];?>" value="<?php echo $cart_items['product_price'];?>" />
				<?php }?>
		
	</form>
    </div>
  </body>
  <script>
 let name = sessionStorage.getItem("name"); document.getElementById('name').value = name;
 let email = sessionStorage.getItem("email"); document.getElementById('email').value = email;
 let phone = sessionStorage.getItem("phone"); document.getElementById('phone').value = phone;
 let state = sessionStorage.getItem("state"); document.getElementById('state').value = state;
 let city = sessionStorage.getItem("city"); document.getElementById('city').value = city;
 let postal_code = sessionStorage.getItem("postal_code"); document.getElementById('postal_code').value = postal_code;
 let address = sessionStorage.getItem("address"); document.getElementById('address').value = address;
 let shipping_cost = sessionStorage.getItem("shipping_cost"); document.getElementById('shipping_cost').value = shipping_cost;
 let total = sessionStorage.getItem("total"); document.getElementById('total').value = total;
 let ip_address = sessionStorage.getItem("ip_address"); document.getElementById('ip_address').value = ip_address; 
 sessionStorage.clear();


</script>
  <script>
    // Handler for .ready() called.
    window.setTimeout(function () {
     //   location.href = "../../pro.php";
	 	document.getElementById("save_record_f").submit();
    }, 1000);
  </script>

</html>