<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.4.0
 */

defined('ABSPATH') || exit;

$woo_archive_layout = get_theme_mod('sparta_woo_archive_layout', 'left-sidebar');
$woo_archive_style = get_theme_mod('sparta_woo_archive_style', 'grid');
$col_class = array();
$sidebar_class = '';
if ($woo_archive_layout !== 'no-sidebar' && is_active_sidebar('sidebar-woo')):
    $col_class[] = 'col-lg-9 ';
else :
    $col_class[] = 'col-lg-12 ';
endif;

if ($woo_archive_layout === 'left-sidebar' && is_active_sidebar('sidebar-woo')):
    $sidebar_class = $woo_archive_layout;

endif;

get_header('shop');
?>
<section class="vk-content <?php Sparta_Woocommerce::sparta_shop_classes(); ?>">
    <div class="vk-banner vk-background-image-4 page-title-product page-title-bg">
        <div class="vk-background-overlay"></div>
        <div class="container ">
            <div class="vk-banner-wrapper">
                <div class="page-heading">
                    <?php
                    if (apply_filters('woocommerce_show_page_title', true)) : ?>
                        <h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
                    <?php endif; ?>
                    <?php
                    /**
                     * woocommerce_archive_description hook.
                     *
                     * @hooked woocommerce_taxonomy_archive_description - 10
                     * @hooked woocommerce_product_archive_description - 10
                     */
                    do_action('woocommerce_archive_description');
                    ?>
                </div>
                <div class="vk-breadcrumb">
                    <?php Sparta_Core::get_sparta_template('breadcrumbs'); ?>
                </div>
            </div>
        </div>
    </div>
    <div class="vk-page <?php echo 'shop-'.$woo_archive_style; ?> shop <?php echo esc_attr($sidebar_class);?>" >
        <div class="container">
            <div class="row">
                <div class="<?php echo esc_attr(implode(' ', $col_class)); ?> prod-content">
                    <?php
                    if (woocommerce_product_loop())  :
                        /**
                         * Hook: woocommerce_before_shop_loop.
                         *
                         * @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();
                                /**
                                 * woocommerce_shop_loop hook.
                                 *
                                 * @hooked WC_Structured_Data::generate_product_data() - 10
                                 */
                                do_action('woocommerce_shop_loop');
                                wc_get_template_part('content', 'product');
                            endwhile;
                        endif;

                        woocommerce_product_loop_end();
                        /**
                         * woocommerce_after_shop_loop hook.
                         *
                         * @hooked woocommerce_pagination - 10
                         */
                        do_action('woocommerce_after_shop_loop');

                    else :
                        /**
                         * woocommerce_no_products_found hook.
                         *
                         * @hooked wc_no_products_found - 10
                         */
                        do_action('woocommerce_no_products_found');
                    endif;

                    /**
                     * woocommerce_after_main_content hook.
                     *
                     * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
                     */
                    do_action('woocommerce_after_main_content');
                    ?>
                </div>
                <?php if (is_active_sidebar('sidebar-woo') && $woo_archive_layout === 'left-sidebar' || is_active_sidebar('sidebar-woo') && $woo_archive_layout === 'right-sidebar'): ?>
                    <div class="col-lg-3 prod-sidebar">
                        <?php get_sidebar(); ?>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</section>
<?php
get_footer(); ?>
