<?php
/**
 * The Template for displaying product archives, including the main shop page.
 *
 * @package Eronex
 * @since 0.0.1
 * @version 8.6.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

get_header();

$general_container = eronex_option( 'eronex_container_layout', 'container' );
$shop_container    = eronex_option( 'eronex_shop_archive_container_layout', $general_container );
$container         = ! empty( $shop_container ) ? $shop_container : $general_container;

$general_sidebar = eronex_option( 'eronex_sidebar_layout', 'right' );
$shop_sidebar    = eronex_option( 'eronex_shop_archive_sidebar_layout', 'none' );
$sidebar         = ! empty( $shop_sidebar ) ? $shop_sidebar : $general_sidebar;
?>
<div class="eronex-<?php echo esc_attr( $container ); ?>">
	<div class="eronex-row">
		<main class="eronex-main">
            <?php
            /**
             * Hook: woocommerce_before_main_content.
             *
             * @since 0.0.1
             *
             * @hooked WC_Structured_Data::generate_website_data() - 30
             */
            do_action( 'woocommerce_before_main_content' );

            if ( woocommerce_product_loop() ) {

                /**
                 * Hook: woocommerce_before_shop_loop.
                 *
                 * @since 0.0.1
                 *
                 * @hooked woocommerce_output_all_notices - 10
                 * @hooked woocommerce_result_count - 20
                 * @hooked woocommerce_catalog_ordering - 30
                 */
                do_action( 'woocommerce_before_shop_loop' );

                woocommerce_product_loop_start();

                if ( wc_get_loop_prop( 'total' ) ) {
                    while ( have_posts() ) {
                        the_post();

                        /**
                         * Hook: woocommerce_shop_loop.
                         *
                         * @since 0.0.1
                         */
                        do_action( 'woocommerce_shop_loop' );

                        wc_get_template_part( 'content', 'product' );
                    }
                }

                woocommerce_product_loop_end();

                /**
                 * Hook: woocommerce_after_shop_loop.
                 *
                 * @since 0.0.1
                 *
                 * @hooked woocommerce_pagination - 10
                 */
                do_action( 'woocommerce_after_shop_loop' );
            } else {
                /**
                 * Hook: woocommerce_no_products_found.
                 *
                 * @since 0.0.1
                 *
                 * @hooked wc_no_products_found - 10
                 */
                do_action( 'woocommerce_no_products_found' );
            }

            /**
             * Hook: woocommerce_after_main_content.
             *
             * @since 0.0.1
             */
            do_action( 'woocommerce_after_main_content' );
            ?>
		</main>
		<?php if ( 'none' !== $sidebar ) { ?>
			<aside class="eronex-aside eronex-aside-<?php echo esc_attr( $sidebar ); ?>">
				<?php
				/**
				 * Fires to output the sidebar markup.
				 *
				 * @since 0.0.1
				 */
				do_action( 'eronex_sidebar' );
				?>
			</aside>
		<?php } ?>
	</div>
</div>
<?php
get_footer();
