<?php
/**
 * This is the default template part for the core shipping-address
 * purchase requirement element in the content-checkout
 * template part.
 *
 *
 * @version 1.1.0
 * @package IT_Exchange
 *
 * WARNING: Do not edit this file directly. To use
 * this template in a theme, copy over this file
 * to the exchange/content-checkout/elements/purchase-requirements directory
 * located in your theme.
*/

$editing_shipping = ( ( ! empty( $_REQUEST['ninja-shop-update-shipping-address'] ) && ! empty( $GLOBALS['it_exchange']['shipping-address-error'] ) ) || ! it_exchange_get_cart_shipping_address() ) ? true : false;
?>
<?php do_action( 'ninja_shop_content_checkout_shipping_address_purchase_requirement_before_element' ); ?>
<div class="ninja-shop-checkout-shipping-address-purchase-requirement">
	<h3><?php _e( 'Shipping Address', 'it-l10n-ithemes-exchange' ); ?></h3>
	<?php if ( false !== ( $shipping_address = it_exchange_get_cart_shipping_address() ) && empty( $editing_shipping ) ) : ?>
		<div class="checkout-purchase-requirement-shipping-address-options">
			<div class="existing-shipping-address">
				<?php echo it_exchange_get_formatted_shipping_address(); ?>
			</div>
		</div>
	<?php endif; ?>
	<div class="<?php echo $editing_shipping ? 'ninja-shop-hidden ' : ''; ?>checkout-purchase-requirement-shipping-address-options">
		<a class="ninja-shop-purchase-requirement-edit-shipping" href=""><?php _e( 'Edit Shipping Address', 'it-l10n-ithemes-exchange' ); ?></a>
	</div>
	<div class="<?php echo $editing_shipping ? '' : 'ninja-shop-hidden '; ?>checkout-purchase-requirement-shipping-address-edit">
		<?php
		$loops = array( 'addresses', 'fields', 'actions' );
		?>
		<div class="ninja-shop-shipping-address-form">
			<?php
			do_action( 'ninja_shop_content_checkout_shipping_address_purchase_requirement_before_form' );
			?>
			<form action="" method="post" >
				<?php
				do_action( 'ninja_shop_content_checkout_shipping_address_purchase_requirement_begin_form' );
				// Include template parts for each of the above loops
				foreach( it_exchange_get_template_part_loops( 'content-checkout/elements/purchase-requirements/shipping-address/loops/', '', $loops ) as $loop ) :
					it_exchange_get_template_part( 'content', 'checkout/elements/purchase-requirements/shipping-address/loops/' . $loop );
				endforeach;
				do_action( 'ninja_shop_content_checkout_shipping_address_purchase_requirement_end_form' );
				?>
			</form>
		</div>
	</div>
</div>
<div class="ninja-shop-clearfix"></div>
<?php do_action( 'ninja_shop_content_checkout_shipping_address_purchase_requirement_after_element' ); ?>
