<?php
/**
 * This is the default template part for the core billing-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_billing = ( ( ! empty( $_REQUEST['ninja-shop-update-billing-address'] ) && ! empty( $GLOBALS['it_exchange']['billing-address-error'] ) ) || ! it_exchange_get_cart_billing_address() ) ? true : false;
?>
<?php do_action( 'ninja_shop_content_checkout_billing_address_purchase_requirement_before_element' ); ?>
<div class="ninja-shop-checkout-billing-address-purchase-requirement">
	<h3><?php _e( 'Billing Address', 'it-l10n-ithemes-exchange' ); ?></h3>
	<?php if ( false !== ( $billing_address = it_exchange_get_cart_billing_address() ) && empty( $editing_billing ) ) : ?>
		<div class="checkout-purchase-requirement-billing-address-options">
			<div class="existing-billing-address">
				<?php echo it_exchange_get_formatted_billing_address(); ?>
			</div>
		</div>
	<?php endif; ?>
	<div class="<?php echo $editing_billing ? 'ninja-shop-hidden ' : ''; ?>checkout-purchase-requirement-billing-address-options">
		<a class="ninja-shop-purchase-requirement-edit-billing" href=""><?php _e( 'Edit Billing Address', 'it-l10n-ithemes-exchange' ); ?></a>
	</div>
	<div class="<?php echo $editing_billing ? '' : 'ninja-shop-hidden '; ?>checkout-purchase-requirement-billing-address-edit">
		<?php
		$loops = array( 'addresses', 'fields', 'actions' );
		?>
		<div class="ninja-shop-billing-address-form">
			<?php
			do_action( 'ninja_shop_content_checkout_billing_address_purchase_requirement_before_form' );
			?>
			<form action="" method="post" >
				<?php
				do_action( 'ninja_shop_content_checkout_billing_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/billing-address/loops/', '', $loops ) as $loop ) :
					it_exchange_get_template_part( 'content', 'checkout/elements/purchase-requirements/billing-address/loops/' . $loop );
				endforeach;
				do_action( 'ninja_shop_content_checkout_billing_address_purchase_requirement_end_form' );
				?>
			</form>
		</div>
	</div>
</div>
<?php if ( ! it_exchange_get_available_shipping_methods_for_cart_products() ) : ?>
	<div class="ninja-shop-clearfix"></div>
<?php endif; ?>
<?php do_action( 'ninja_shop_content_checkout_billing_address_purchase_requirement_after_element' ); ?>
