function sunshine_checkout_shipping_fields()
{
    ?>
	<script type="text/javascript">
	jQuery(document).ready(function() {

		jQuery('form').on('change', 'select[name="shipping_country"]', function(){
			var shipping_country = jQuery(this).val();
			setTimeout(function () {
				jQuery.ajax({
				  	type: 'POST',
				  	url: '<?php 
    echo admin_url('admin-ajax.php');
    ?>
',
				  	data: {
				  		action: 'sunshine_checkout_update_shipping_state',
						shipping_country: shipping_country
					},
				  	success: function(data, textStatus, XMLHttpRequest) {
						var obj = jQuery.parseJSON(data);
						if (obj.state_options)
							jQuery('#sunshine-shipping-state').html('<label>State / Province '+obj.state_options+'</label>');
				  	},
				  	error: function(MLHttpRequest, textStatus, errorThrown) {
						alert('Sorry, there was an error with your request');
				  	}
				});
			}, 500);
			return false;
		});
	
	});
	</script>
	<fieldset id="sunshine-shipping-fields">
		<h2><?php 
    _e('Shipping Information', 'sunshine');
    ?>
</h2>
		<div class="field field-left required"><label><?php 
    _e('Country', 'sunshine');
    ?>
<span class="required">*</span> <?php 
    SunshineCountries::country_only_dropdown('shipping_country', SunshineUser::get_user_meta('shipping_country'));
    ?>
</label></div>
		<div class="field field-left required"><label><?php 
    _e('First Name', 'sunshine');
    ?>
<span class="required">*</span> <input type="text" name="shipping_first_name" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_first_name'));
    ?>
" /></label></div>
		<div class="field field-right required"><label><?php 
    _e('Last Name', 'sunshine');
    ?>
<span class="required">*</span> <input type="text" name="shipping_last_name" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_last_name'));
    ?>
" /></label></div>
		<div class="field field-left required"><label><?php 
    _e('Address', 'sunshine');
    ?>
<span class="required">*</span> <input type="text" name="shipping_address" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_address'));
    ?>
" /></label></div>
		<div class="field field-right"><label><?php 
    _e('Address 2', 'sunshine');
    ?>
 <input type="text" name="shipping_address2" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_address2'));
    ?>
" /></label></div>
		<div class="field field-left required"><label><?php 
    _e('City', 'sunshine');
    ?>
<span class="required">*</span> <input type="text" name="shipping_city" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_city'));
    ?>
" /></label></div>
		<div class="field field-right required" id="sunshine-shipping-state"><label><?php 
    _e('State / Province', 'sunshine');
    ?>
<span class="required">*</span> <?php 
    SunshineCountries::state_dropdown(SunshineUser::get_user_meta('shipping_country'), 'shipping_state', SunshineUser::get_user_meta('shipping_state'));
    ?>
</label></div>
		<div class="field field-left required"><label><?php 
    _e('Zip / Postcode', 'sunshine');
    ?>
<span class="required">*</span> <input type="text" name="shipping_zip" value="<?php 
    echo esc_attr(SunshineUser::get_user_meta('shipping_zip'));
    ?>
" /></label></div>
<?php 
    do_action('sunshine_checkout_shipping_fields');
    echo '</fieldset>';
}
function sunshine_add_order_data()
{
    ?>
	<form method="post">
	<p>
		<?php 
    _e('Customer', 'sunshine');
    ?>
:<br />
		<select name="customer" class="sunshine-multiselect">
			<option value=""><?php 
    _e('Guest', 'sunshine');
    ?>
</option>
			<?php 
    $users = get_users();
    foreach ($users as $user) {
        echo '<option value="' . $user->ID . '">' . $user->display_name . '</option>';
    }
    ?>
		</select>
	</p>
	<p id="email">
		<?php 
    _e('Email', 'sunshine');
    ?>
<br />
		<input type="email" name="email" />
	</p>
	<p>
		<?php 
    _e('Order Date', 'sunshine');
    ?>
:<br />
		<input type="text" name="date" class="datepicker" />
	</p>
	<p>
		<?php 
    _e('Order Status', 'sunshine');
    ?>
<br />
		<select name="status">
			<?php 
    $statuses = get_terms('sunshine-order-status', 'hide_empty=0&orderby=id&order=ASC');
    foreach ($statuses as $status) {
        echo '<option value="' . $status->term_id . '">' . $status->name . '</option>';
    }
    ?>
		</select>
	</p>
	<div style="width: 45%; float: left;">
		<h4><?php 
    _e('Billing Information', 'sunshine');
    ?>
</h4>
		<p>
			<?php 
    _e('Country', 'sunshine');
    ?>
<br />
			<?php 
    SunshineCountries::country_only_dropdown('country', '');
    ?>
		</p>
		<p>
			<?php 
    _e('First Name', 'sunshine');
    ?>
<br />
			<input type="text" name="first_name" />
		</p>
		<p>
			<?php 
    _e('Last Name', 'sunshine');
    ?>
<br />
			<input type="text" name="last_name" />
		</p>
		<p>
			<?php 
    _e('Address', 'sunshine');
    ?>
<br />
			<input type="text" name="address" />
		</p>
		<p>
			<?php 
    _e('Address 2', 'sunshine');
    ?>
<br />
			<input type="text" name="address2" />
		</p>
		<p>
			<?php 
    _e('City', 'sunshine');
    ?>
<br />
			<input type="text" name="city" />
		</p>
		<p id="sunshine-billing-state">
			<?php 
    _e('State', 'sunshine');
    ?>
<br />
			<?php 
    SunshineCountries::state_dropdown('', 'state', '');
    ?>
		</p>
	</div>
	<div style="width: 45%; float: right;">
		<h4><?php 
    _e('Shipping Information', 'sunshine');
    ?>
</h4>
	<p>
		<?php 
    _e('Country', 'sunshine');
    ?>
<br />
		<?php 
    SunshineCountries::country_only_dropdown('shipping_country', '');
    ?>
	</p>
	<p>
		<?php 
    _e('First Name', 'sunshine');
    ?>
<br />
		<input type="text" name="shipping_first_name" />
	</p>
	<p>
		<?php 
    _e('Last Name', 'sunshine');
    ?>
<br />
		<input type="text" name="shipping_last_name" />
	</p>
	<p>
		<?php 
    _e('Address', 'sunshine');
    ?>
<br />
		<input type="text" name="shipping_address" />
	</p>
	<p>
		<?php 
    _e('Address 2', 'sunshine');
    ?>
<br />
		<input type="text" name="shipping_address2" />
	</p>
	<p>
		<?php 
    _e('City', 'sunshine');
    ?>
<br />
		<input type="text" name="shipping_city" />
	</p>
	<p id="sunshine-shipping-state">
		<?php 
    _e('State', 'sunshine');
    ?>
<br />
		<?php 
    SunshineCountries::state_dropdown('', 'shipping_state', '');
    ?>
	</p>
	</div>
	<br clear="both" />

	<h4><?php 
    _e('Order Items', 'sunshine');
    ?>
</h4>
	<table style="width: 100%;">
	<tr>
		<th><?php 
    _e('Gallery', 'sunshine');
    ?>
</th>
		<th><?php 
    _e('Image', 'sunshine');
    ?>
</th>
		<th><?php 
    _e('Product', 'sunshine');
    ?>
</th>
		<th><?php 
    _e('Qty', 'sunshine');
    ?>
</th>
		<th><?php 
    _e('Item Total', 'sunshine');
    ?>
</th>
	</tr>
	<tr>
		<td>
			<select name="gallery">
				<option value=""><?php 
    _e('Select gallery', 'sunshine');
    ?>
</option>
				<?php 
    $galleries = get_posts('post_type=sunshine-gallery&nopaging=true');
    foreach ($galleries as $gallery) {
        echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . '</option>';
    }
    ?>
			</select>
		</td>
		<td>
			<select name="image[]">
			</select>
		</td>
		<td>
			<select name="product[]">

			</select>
		</td>
		<td>
		</td>
	</tr>
	</table>

	</form>

	<script>
	jQuery( document ).ready( function($) {
		$(".sunshine-multiselect").select2({
		    width: '100%',
			allowClear: true
		});

		$( 'select[name="customer"]' ).change(function(){
			if ( $( this ).val() == '' ) {
				$( '#email' ).show();
			} else {
				$( '#email' ).hide();
			}
		});

		jQuery('.datepicker').datepicker( {
			dateFormat: '<?php 
    echo sunshine_date_format_php_to_js(get_option('date_format'));
    ?>
',
			gotoCurrent: true,
		}).keyup(function(e) {
		    if(e.keyCode == 8 || e.keyCode == 46) {
		        $.datepicker._clearDate(this);
		    }
		});

		// Changing state selection
		jQuery('form').on('change', 'select[name="country"]', function(){
			var country = jQuery(this).val();
			setTimeout(function () {
				jQuery.ajax({
				  	type: 'POST',
				  	url: '<?php 
    echo admin_url('admin-ajax.php');
    ?>
',
				  	data: {
				  		action: 'sunshine_checkout_update_state',
						country: country,
					},
				  	success: function(data, textStatus, XMLHttpRequest) {
						var obj = jQuery.parseJSON(data);
						if (obj.state_options)
							jQuery('#sunshine-billing-state').html('<label><?php 
    _e('State / Province', 'sunshine');
    ?>
 '+obj.state_options+'</label>');
				  	},
				  	error: function(MLHttpRequest, textStatus, errorThrown) {
						alert('Sorry, there was an error with your request');
				  	}
				});
			}, 500);
			return false;
		});

		jQuery('form').on('change', 'select[name="shipping_country"]', function(){
			var shipping_country = jQuery(this).val();
			setTimeout(function () {
				jQuery.ajax({
				  	type: 'POST',
				  	url: '<?php 
    echo admin_url('admin-ajax.php');
    ?>
',
				  	data: {
				  		action: 'sunshine_checkout_update_shipping_state',
						shipping_country: shipping_country
					},
				  	success: function(data, textStatus, XMLHttpRequest) {
						var obj = jQuery.parseJSON(data);
						if (obj.state_options)
							jQuery('#sunshine-shipping-state').html('<label>State / Province '+obj.state_options+'</label>');
				  	},
				  	error: function(MLHttpRequest, textStatus, errorThrown) {
						alert('Sorry, there was an error with your request');
				  	}
				});
			}, 500);
			return false;
		});

	});
	</script>

<?php 
}