<?php
/**
 * Availability check for accommodation.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/hbfwc/availability-check.php.
 *
 * @package HBFWC\Templates
 * @version 1.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Hook: hbfwc_template_before_accommodation_loop.
 *
 * @hooked hbfwc_template_shortcode_wrapper - 10 (outputs opening divs for the content)
 * @hooked hbfwc_template_availability_filter_form - 20 (outputs the filter form)
 */
do_action( 'hbfwc_template_before_accommodation_loop', $query_args );

$query_args['checkin']  = strtotime( $query_args['checkin'] );
$query_args['checkout'] = strtotime( $query_args['checkout'] );

$accommodations = new HBFWC_Shortcode_Loop( $query_args );

if ( $accommodations->has_posts ) {

	hbfwc_template_loop_start();

	foreach ( $accommodations->get_ids() as $accommodation_id ) {

		/**
		 * Hook: hbfwc_template_accommodation_loop.
		 *
		 * @hooked hbfwc_template_availability_loop_content - 10
		 */
		do_action( 'hbfwc_template_accommodation_loop', $accommodation_id, $query_args );

	}

	hbfwc_template_loop_before_sidebar();

	do_action( 'hbfwc_template_accommodation_sidebar' );

	hbfwc_template_loop_end();

} else {
	/**
	 * Hook: hbfwc_template_accommodation_not_found.
	 *
	 * @hooked hbfwc_template_availability_loop_not_found - 20
	 */
	do_action( 'hbfwc_template_accommodation_not_found' );

}

/**
 * Hook: hbfwc_template_after_accommodation_loop.
 *
 * @hooked hbfwc_template_shortcode_wrapper_end - 30 (outputs closing divs for the content)
 */
do_action( 'hbfwc_template_after_accommodation_loop' );
