<div class="breadcrumb-area bg--white-6 breadcrumb-bg-1 pt--60 pb--70 pt-lg--40 pb-lg--50 pt-md--30 pb-md--40">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12 text-center">
                        <h1 class="page-title">Checkout</h1>
                        <ul class="breadcrumb justify-content-center">
                            <li><a href="<?php echo base_url();?>" style="color:#fff;">Home&nbsp;&nbsp;&nbsp;&nbsp;/</a></li>
                            <li class="current"><span style="color:#fff;">Checkout</span></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- Breadcrumb area End -->
        <style>
		.selected_acl{border:2px solid #F90;}
		</style>
		<script>
		$(document).ready(function(){
				$("#show_new").click(function(){
					$("#new_address_div").show();
					$(".old_adds").removeClass("selected_acl");
					$(".old_adds").hide();
					$(".required").attr("required",true);
				});
				$("#show_old").click(function(){
					$("#new_address_div").hide();
					$(".old_adds").show();
				});
				$(".select_address").click(function(){
					var id=$(this).attr("id");
					var qty=$("#qty").val();
					var addid=$(this).attr("addid");
					$(".old_adds").removeClass("selected_acl");
					$("#add"+id).addClass("selected_acl");
					$("#oldadd").val(id);
					$(".required").removeAttr("required");
					$.ajax({
						 type: "POST",
						 url: '<?php echo base_url();?>home/ajax_shipping2',
						 data: {id:addid,qty:qty},
						 success: function(res){
							 console.log(res);
							 var d=res.split("|");
							 $("#shipping_amt").text(d[0]);
							 $("#total_amt").text(d[1]);
						}
					});
				});
				$("#state").change(function(){
					var id=$(this).val();
					var qty=$("#qty").val();
					$.ajax({
						 type: "POST",
						 url: '<?php echo base_url();?>home/ajax_shipping2',
						 data: {id:id,qty:qty},
						 success: function(res){
							 console.log(res);
							 var d=res.split("|");
							 $("#shipping_amt").text(d[0]);
							 $("#total_amt").text(d[1]);
							 //alert(res);
						}
					});
				});
				$("#button-coupon").click(function(){
					var code=$("#input-coupon").val();
					var qty=$("#qty").val();
					if(code==''){alert("please enter valid coupon code");return false;}
					$(".coupon_div").show();
					$.ajax({
						 type: "POST",
						 url: '<?php echo base_url();?>home/ajax_apply_code2',
						 data: {code:code,qty:qty},
						 success: function(res){
							 console.log(res);
							 if(res==0){
								$(".coupon_div").html('<b>Invalid Coupon Code</b>'); 
							 }else{
								var r=res.split('=');
								$("#dis_text").text(r[0]);
								$("#discount_val").val(r[0]);
								$("#oinflu_id").val(r[2]);
								$("#total_amt").text(r[1]); 
								$(".coupon_div").html('<b>Coupon code '+code+' applied successfully.</b>'); 
							 }
							// $(".instant-results").slideDown();
							 //$(".result-bucket").html(res);
						}
					});
				});
		});
		</script>
        <!-- Main Content Wrapper Start -->
        <div id="content" class="main-content-wrapper">
            <div class="page-content-inner">
                <div class="container">
                    <div class="row pt--80 pt-md--60 pt-sm--40">
                        <div class="col-12">
                            <!-- User Action Start -->
                            
                            <!-- User Action End -->
                        </div>
                    </div>
       					<form action="<?php echo base_url();?>home/place_order2" method="post" class="checkout-form">
                        <input type="hidden" name="oldadd" id="oldadd" value="" />
                    	<div class="row pb--80 pb-md--60 pb-sm--40">
                        <!-- Checkout Area Start -->
                        <div class="col-xl-6  col-lg-6 mt-md--40">
                            <div class="checkout-title mt--10">
                                <h2>Billing/Shipping Details</h2>
                            </div>
                            <?php 
							$this->db->select("*");
							$this->db->from("user_adds");
							//$this->db->join("cities","cities.city_id=user_adds.add_city");
							$this->db->where("user_adds.userid",$this->session->userdata("user"));
							$add=$this->db->get();
							if($add->num_rows()>0){
								$adds=$add->result();
								//echo "<pre>";print_r($adds);
							foreach($adds as $addr){?>
                            <div style="padding:10px; background:#eee; margin-top:10px;" class="old_adds" id="add<?php echo $addr->user_add_id;?>">
                            <h4><?php echo $addr->add_name.' '.$addr->add_phone;?></h4>
                            <p><?php echo $addr->add_address.' '.$addr->add_landmark.' '.$addr->add_city.' '.$addr->add_state_name.' '.$addr->add_pin;?></p>
                            <button type="button" class="btn btn-warining select_address" addid="<?php echo $addr->uadd_state_code;?>" id="<?php echo $addr->user_add_id;?>">Select Address</button>
                            </div>
                            <?php }?>
                            <button type="button" id="show_new">Add New Address</button>
                            <?php }?>
                            <div class="checkout-form" id="new_address_div" <?php if($add->num_rows()>0){echo 'style="display:none;"';}?>>
                            <?php if($add->num_rows()>0){?>
                            <button type="button" id="show_old">Select Old Address</button>
                            <?php }?>
                                    <div class="row mb--30">
                                        <div class="form__group col-md-8 mb-sm--30">
                                            <label for="billing_fname" class="form__label form__label--2">Name
                                                <span class="required">*</span></label>
                                            <input type="text" name="name" value="<?php echo $this->session->userdata("name");?>" required class="form__input form__input--2">
                                        </div>
                                        <div class="form__group col-md-4 mb-sm--30">
                                            <label for="billing_fname" class="form__label form__label--2">Mobile
                                                <span class="required">*</span></label>
                                            <input type="text" name="mobile" required value="<?php echo $this->session->userdata("phone");?>" class="form__input form__input--2">
                                        </div>
                                    </div>
                                    <div class="row mb--30">
                                        <div class="form__group col-12">
                                            <label for="billing_country" class="form__label form__label--2">State
                                                <span class="required">*</span></label>
                                            <select id="state" name="state" required class="form-control required">
                                                <option value="">Select State</option>
                                                <?php $states=$this->db->get_where("states",array("country_id"=>101))->result();
												foreach($states as $st){?>
                                                <option value="<?php echo $st->state_id;?>"><?php echo $st->state_name;?></option>
                                                <?php }?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row mb--30">
                                        <div class="form__group col-12">
                                            <label for="billing_streetAddress" class="form__label form__label--2">Street
                                                Address <span class="required">*</span></label>

                                            <input type="text" name="add1" required id="billing_streetAddress"
                                                class="form__input form__input--2 mb--30 required"
                                                placeholder="House number and street name">

                                            <input type="text" name="add2" id="billing_apartment"
                                                class="form__input form__input--2"
                                                placeholder="Apartment, suite, unit etc. (optional)">
                                        </div>
                                    </div>
                                    <div class="row mb--30">
                                        <div class="form__group col-8">
                                            <label for="billing_city" class="form__label form__label--2">Town / City
                                                <span class="required">*</span></label>
                                            <input type="text" name="city" required
                                                class="form__input form__input--2 required">
                                        </div>
                                        <div class="form__group col-4">
                                            <label for="billing_city" class="form__label form__label--2">Pincode<span class="required">*</span></label>
                                            <input type="text" required name="pincode" class="form__input form__input--2 required">
                                        </div>
                                    </div>
                                    
                            </div>
                        </div>
                        <div class="col-xl-4 offset-md-1 col-lg-4 mt-md--40">
                            <div class="order-details">
                                <div class="checkout-title mt--10">
                                    <h2>Your Order</h2>
                                </div>
                                <div class="user-actions user-actions__coupon">
                                <div class="message-box mb--30 mb-sm--20">
                                    <p><i class="fa fa-exclamation-circle"></i> Have A Coupon? <a class="expand-btn"
                                            href="#coupon_info">Click Here To Enter Your Code.</a></p>
                                </div>
                                <div id="coupon_info" class="user-actions__form hide-in-default">
                                        <p>If you have a coupon code, please apply it below.</p>
                                        <div class="form__group d-sm-flex">
                                            <input type="text" name="coupon" autocomplete="off" id="input-coupon"
                                                class="form__input form__input--2 mr--20 mr-xs--0"
                                                placeholder="Coupon Code">
                                                <input type="hidden" name="discount" value="" id="discount_val" />
                                                <input type="hidden" name="influ_id" value="" id="oinflu_id" />
                                        </div>
                                            <button type="button" id="button-coupon" class="btn btn-medium btn-style-1">Apply
                                                Coupon</button>
                                                <div class="alert alert-warning coupon_div"></div>
                                </div>
                            </div>
                                <div class="table-content table-responsive mb--30">
                                    <table class="table order-table order-table-2">
                                        <thead>
                                            <tr>
                                                <th>Product</th>
                                                <th class="text-end">Total</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                        					<?php //foreach($this->cart->contents() as $cart){?>
                                            <input type="hidden" name="qty" id="qty" value="<?php echo $cart['qty'];?>" />
                                            <input type="hidden" name="pid" value="<?php echo $cart['id'];?>" />
                                            <input type="hidden" name="price" value="<?php echo $cart['price'];?>" />
                                            <input type="hidden" name="warranty" value="<?php echo $cart['warranty'];?>" />
                                            <input type="hidden" name="pname" value="<?php echo $cart['name'];?>" />
                                            <input type="hidden" name="pimg" value="<?php echo $cart['img'];?>" />
                                            <tr>
                                                
                                                <th><?php echo $cart['name'];?><br/><strong><?php echo $cart['price'];?> x <?php echo $cart['qty'];?></strong>
                                                </th>
                                                <td class="text-end"><?php echo $cart['price']*$cart['qty'];?></td>
                                            </tr>
                                            <?php //}?>
                                        </tbody>
                                        <tfoot>
                                            <tr class="cart-subtotal">
                                                <th>Subtotal</th>
                                                <td class="text-end"><?php echo $cart['price']*$cart['qty'];?></td>
                                            </tr>
                                            <tr class="shipping">
                                                <th>Shipping</th>
                                                <td class="text-end">
                                                    <span id="shipping_amt">0</span>
                                                </td>
                                            </tr>
                                            <tr class="shipping">
                                                <th>Discount</th>
                                                <td class="text-end">
                                                    <span id="dis_text">0</span>
                                                </td>
                                            </tr>
                                            <tr class="order-total">
                                                <th>Order Total</th>
                                                <td class="text-end"><span class="order-total-ammount" id="total_amt"><?php echo $cart['price']*$cart['qty'];?></span>
                                                </td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </div>
                                <div class="checkout-payment">
                                        <div class="payment-group mb--10">
                                            <div class="payment-radio">
                                                <input type="radio" value="PayU" name="payment_method" id="bank"
                                                    checked>
                                                <label class="payment-label" for="cheque">Pay Online</label>
                                            </div>
                                            <div class="payment-info" data-method="bank">
                                                <p>Make your payment using Debit/Credit Card or wallet/UPI</p>
                                            </div>
                                        </div>
                                        
                                        <div class="payment-group mb--10">
                                            <div class="payment-radio">
                                                <input type="radio" value="COD" name="payment_method" id="cash">
                                                <label class="payment-label" for="cash">
                                                    CASH ON DELIVERY
                                                </label>
                                            </div>
                                            <div class="payment-info cash hide-in-default" data-method="cash">
                                                <p>Pay with cash upon delivery.</p>
                                            </div>
                                        </div>
                                        <div class="payment-group mt--20">
                                            <button type="submit" class="btn btn-fullwidth btn-style-1">Place Order</button>
                                        </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Checkout Area End -->
                    </div>
                                </form>
                </div>
            </div>
        </div>