<div class="page-margin">
	<h2 class="ch_checkout_title"><?php echo $wo['lang']['checkout'] ?></h2>
	<div class="row">
		<div class="col-md-5">
			<h4><?php echo $wo['lang']['delivery_address'] ?></h4>
			<div class="panel panel-white ch_card ch_summary">
				<div class="checkout_alert"></div>

				<ul class="list-unstyled mb-0 cart_chos_addrs">
					<?php
						if (!empty($wo['addresses'])) {
							foreach ($wo['addresses'] as $key => $address) {
								?>
						<li>
							<input type="radio" name="choose-address" id="choose_adrs_<?php echo($address->id) ?>" value="<?php echo($address->id) ?>" class="payment_address">
							<label for="choose_adrs_<?php echo($address->id) ?>">
								<p><b><?php echo($address->name) ?></b>&nbsp;<?php echo($address->phone) ?></p>
								<p><?php echo($address->country) ?>, <?php echo($address->city) ?> - <?php echo($address->zip) ?></p>
							</label>
						</li>
					<?php  } } ?>
				</ul>
			</div>
			<h4><?php echo $wo['lang']['add_new_address'] ?></h4>
			<form class="form form-horizontal address_form" method="post" action="#">
				<div class="panel panel-white ch_card ch_address">
					<div class="modal_add_address_modal_alert"></div>
					<div class="clear"></div>
					<div class="row">
						<div class="col-md-12">
							<div class="sun_input">
								<label><?php echo $wo['lang']['name']; ?></label>
								<input name="name" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['name']; ?>" value="<?php echo($wo['user']['name']) ?>">
							</div>
						</div>
						<div class="col-md-6">
							<div class="sun_input">
								<label><?php echo $wo['lang']['phone_number']; ?></label>
								<input name="phone" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['phone_number']; ?>" value="<?php echo($wo['user']['phone_number']) ?>">
							</div>
						</div>
						<div class="col-md-6">
							<div class="sun_input">
								<label><?php echo $wo['lang']['country']; ?></label>
								<input id="country" name="country" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['country']; ?>">
							</div>
						</div>
						<div class="col-md-6">
							<div class="sun_input">
								<label><?php echo $wo['lang']['city']; ?></label>
								<input id="city" name="city" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['city']; ?>">
							</div>
						</div>
						<div class="col-md-6">
							<div class="sun_input">
								<label><?php echo $wo['lang']['zip']; ?></label>
								<input id="zip" name="zip" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['zip']; ?>">
							</div>
						</div>
						<div class="col-md-12">
							<div class="sun_input">
								<label><?php echo $wo['lang']['address']; ?></label>
								<textarea class="form-control input-md" placeholder="<?php echo $wo['lang']['address']; ?>" name="address"></textarea>
							</div>
						</div>
					</div>
					<div class="clear"></div>
					<button type="submit" class="btn btn-default btn-block btn-mat"><?php echo $wo['lang']['add']; ?></button>
				</div>
			</form>
		</div>
		<div class="col-md-7">
			<div class="panel panel-white ch_card ch_cart">
                <div class="ch_title">
					<div>
						<h4>
							<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17,18C15.89,18 15,18.89 15,20A2,2 0 0,0 17,22A2,2 0 0,0 19,20C19,18.89 18.1,18 17,18M1,2V4H3L6.6,11.59L5.24,14.04C5.09,14.32 5,14.65 5,15A2,2 0 0,0 7,17H19V15H7.42A0.25,0.25 0 0,1 7.17,14.75C7.17,14.7 7.18,14.66 7.2,14.63L8.1,13H15.55C16.3,13 16.96,12.58 17.3,11.97L20.88,5.5C20.95,5.34 21,5.17 21,5A1,1 0 0,0 20,4H5.21L4.27,2M7,18C5.89,18 5,18.89 5,20A2,2 0 0,0 7,22A2,2 0 0,0 9,20C9,18.89 8.1,18 7,18Z" fill="currentColor"/></svg> <?php echo $wo['lang']['shopping_cart'] ?>
						</h4>
						<p><?php echo(!empty($wo['items']) ? count($wo['items']) : 0) ?> <?php echo $wo['lang']['items'] ?></p>
					</div>
					<a href="<?php echo $wo['config']['site_url'].'/products';?>" data-ajax="?link1=products" class="back-to-shop">
						<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path fill="currentColor" d="M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z" /></svg> <?php echo $wo['lang']['back_to_shop'] ?>
					</a>
                </div>
				<div class="row ch_prod_items_row">
					<?php
						if (!empty($wo['html'])) {
							echo $wo['html'];
						} else {
							echo '<div class="center-text empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shopping-cart"><circle cx="9" cy="21" r="1"></circle><circle cx="20" cy="21" r="1"></circle><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path></svg>' . $wo['lang']['no_items_found'] . '</div>';
						}
					?>
				</div>
				<div class="ch_total_price">
					<div class="divider border-bottom"></div>
					<?php if ($wo['topup'] == 'show') { ?>
						<div class='alert alert-danger wallet_alert'><i class='fa fa-info-circle'></i> <a href='<?php echo $wo['config']['site_url'].'/wallet';?>' target="_blank"><?php echo $wo["lang"]["please_top_up_wallet"]?></a></div>
					<?php } ?>
					<h4><?php echo $wo['lang']['total'] ?></h4>
					<p><?php echo $wo['config']['currency_symbol_array'][$wo['config']['currency']]; ?><?php echo $wo['total']; ?></p>
					<div class="divider border-bottom"></div>
					<button type="button" class="btn btn-success btn-mat buy_button" onclick="BuyProducts('hide','<?php echo $wo['total']; ?>')" <?php if ($wo['topup'] == 'show' || empty($wo['addresses'])) { ?>disabled="true"<?php } ?>><?php echo $wo['lang']['buy'] ?></button>
					<svg width="371" height="218" viewBox="0 0 371 218" fill="none" xmlns="http://www.w3.org/2000/svg"><path opacity="0.4" d="M275.008 41.3416C307.369 28.1561 375.43 47.6713 391.786 57.0941L410.44 43.2371L532.518 -219.202L71.3192 -143.669C60.4225 -120.263 39.7451 -60.5365 44.2096 -8.88462C49.7902 55.6802 112.183 99.047 174.223 94.1242C232.5 89.5 234.557 57.8234 275.008 41.3416Z" fill="#48B774" stroke="white"/><path d="M300.467 72.6242C332.827 59.4387 663.274 90.2678 679.63 99.6906L766.842 -127.791L557.976 -187.919L96.7778 -112.387C85.881 -88.9802 65.2036 -29.2539 69.6681 22.398C75.2487 86.9628 136.92 125.407 199.682 125.407C262.5 125.407 260.016 89.1061 300.467 72.6242Z" stroke="#48B774" stroke-width="6"/></svg>
				</div>
			</div>
		</div>
	</div>
</div>

<script>

$(document).ready(function() {
    var options = {
      url: Wo_Ajax_Requests_File() + '?f=address&s=add&hash=' + $('.main_session').val(),
        beforeSubmit:  function () {
          $('.modal_add_address_modal_alert').empty();
          $("#add_address_modal").find('.btn-mat').attr('disabled', 'true');
          $("#add_address_modal").find('.btn-mat').text("<?php echo($wo['lang']['please_wait']) ?>");
        },
        success: function (data) {
          $("#add_address_modal").find('.btn-mat').text("<?php echo $wo['lang']['add'] ?>");
          $("#add_address_modal").find('.btn-mat').removeAttr('disabled')
          if (data.status == 200) {
            $('.modal_add_address_modal_alert').html('<div class="alert alert-success bg-success"><i class="fa fa-check"></i> '+
              data.message
              +'</div>');
              if (data.url && data.url != '') {
                if ($('#setting_address_page').length > 0) {
                  setTimeout(function () {
                    location.href = data.url;
                  },2000);
                }
                else{
                  setTimeout(function () {
                    $('.modal_add_address_modal_alert').empty();
              $("#add_address_modal").find('.btn-mat').removeAttr('disabled')
              $("#add_address_modal").find('.btn-mat').text("<?php echo $wo['lang']['add'] ?>");
              $('#add_address_modal').modal('hide');
              $('#load_checkout').click();
                  },2000);
                }
              }
          } else {
            $('.modal_add_address_modal_alert').html('<div class="alert alert-danger bg-danger"> '+
            data.message
            +'</div>');
          }
        }
    };
    $('.address_form').ajaxForm(options);
});
    <?php if ($wo['topup'] == 'show') { ?>
    var check_wallet = setInterval(function(){
        $.post(Wo_Ajax_Requests_File() + '?f=products&s=check_wallet&hash=' + $('.main_session').val(), function(data, textStatus, xhr) {
            if (data.status == 200) {
                if (data.topup == 'hide') {
                    $('.wallet_alert').remove();
                    $('.buy_button').removeAttr('disabled');
                    clearInterval(check_wallet);
                }
            }
        });
     }, 3000);
    <?php } ?>
</script>
