<?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();

inoby_enqueue_parted_style("product", "post_types");
inoby_enqueue_parted_script("product", "post_types");
get_header("shop");
?>

<?php get_template_part("template-parts/yoast-breadcrumbs", "yoast-breadcrumbs"); ?>

<div class="container container-fluid woocommerce-hero">
  <div class="row">
    <div class="col-12">
      <header class="woocommerce-products-header">
        <div class="products-header-content-wrap">
          <?php if (apply_filters("woocommerce_show_page_title", true)): ?>
          <div class="products-header-title">
            <h1 class="woocommerce-products-header__title page-title"><?php echo woocommerce_page_title(); ?></h1>
          </div>
          <?php endif; ?>
          <div class="products-header-desc">
            <?php //

// Hook woocommerce_archive_description.
            // @hooked woocommerce_taxonomy_archive_description - 10
            // @hooked woocommerce_product_archive_description - 10

            do_action("woocommerce_archive_description"); ?>
          </div>
        </div>
        <?php do_action("inoby_shop_archive_after_category_description"); ?>
      </header>
    </div>
  </div>
</div>

<div class="container container-fluid products-wrp">
  <div class="row">
    <?php if (!is_search() && Inoby_Config::show_shop_sidebar("true")): ?>
      <div id="products-sidebar" class="col">
        <?php do_action("woocommerce_sidebar"); ?>
      </div>
      <?php endif; ?>
      <div id="products-main" class="col">
      <?php
/**
        *  zakomentovane pretoze tam nepotrebujeme elementy <div id="primary" class="content-area container"><main id="main" class="site-main" role="main"> ...</main></div>
       */
// do_action("woocommerce_before_main_content");
?>
      <?php rc_shop_subcategories(); ?>
      <?php
      /**
       * Hook: woocommerce_before_shop_loop.
       *
       * @hooked woocommerce_output_all_notices - 10
       * @hooked woocommerce_result_count - 20
       * @hooked woocommerce_catalog_ordering - 30
       */
      echo '<div class="order-by-wrap">';
      do_action("woocommerce_before_shop_loop");
      echo "</div>";
      do_action("rc_filter_items");
      woocommerce_product_loop_start();

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

          /**
           * Hook: woocommerce_shop_loop.
           */
          do_action("woocommerce_shop_loop");

          $b2b_as_global_sale = rwmb_meta( 'b2b-global-sale' , ["object_type" => "setting"], "options");
          if (ESHOP_ENABLED && Inoby_Config::b2b() && !empty($b2b_as_global_sale) && $b2b_as_global_sale && is_user_logged_in() && wc_current_user_has_role('b2b')) {
            get_template_part("post-types/product-b2b/content-product-b2b");
          } else {
            wc_get_template_part("content", "product");
          }
        } ?>
      <?php rc_shop_pagination(wc_get_loop_prop("total_pages"), wc_get_loop_prop("current_page")); ?>
      <?php
      } else {
        /**
         * Hook: woocommerce_no_products_found.
         *
         * @hooked wc_no_products_found - 10
         */
        do_action("woocommerce_no_products_found");
      }
      woocommerce_product_loop_end();
      ?>

      <?php
/**
       * Hook: woocommerce_after_main_content.
       *
       * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
       */
/**
        *  zakomentovane ukoncenie do_action("woocommerce_before_main_content");
       */
// do_action("woocommerce_after_main_content");
?>
    </div>
  </div>
</div>
<?php
do_action("inoby_after_shop_archive");
get_footer("shop");

