<?php
/**
 * Template Name: Custom Home Page
 */
get_header();

?>
<!-- banner section -->
<main id="maincontent" role="main">

<?php do_action('commercial_automation_services_before_banner'); ?>
  <section id="banner" class="wow bounceInLeft delay-1000 position-relative d-flex align-items-center" data-wow-duration="3s">
    <div class="container ">
      <div class="row">
        <div class="col-xl-7 col-lg-7 col-md-7">
          <div class="inner-banner">
            <?php if(get_theme_mod('commercial_automation_services_banner_small_title') != '') {?>
              <span class="banner-grp-img1"><?php echo esc_html(get_theme_mod('commercial_automation_services_banner_small_title')) ?></span>
            <?php }?>
            <?php if (get_theme_mod('commercial_automation_services_slider_tagline_title') != ''): ?>
              <h1 class="banner-heading text-lg-start text-md-start text-sm-center text-center">
                <span class="span-class">
                  <i class="<?php echo esc_attr(get_theme_mod('commercial_automation_services_banner_heading_icon', 'fa-solid fa-arrow-right')); ?> ms-2"></i>
                </span> <?php echo esc_html(get_theme_mod('commercial_automation_services_slider_tagline_title')); ?>
              </h1>
            <?php endif; ?>
            <?php if(get_theme_mod('commercial_automation_services_slider_text') != '') {?>
              <p class="banner-content"><?php echo esc_html(get_theme_mod('commercial_automation_services_slider_text')) ?></p>
            <?php }?>
            <div class="d-flex gap-4 align-items-center banner-btns">
              <?php if ( get_theme_mod('commercial_automation_services_banner_button_text') != '' || get_theme_mod('commercial_automation_services_banner_small_title_icon') != '' ) {?>
                <div class ="read-more">
                  <a href="<?php echo esc_url(get_theme_mod('commercial_automation_services_banner_btn_link',false));?>"><?php echo esc_html(get_theme_mod('commercial_automation_services_banner_button_text'));?>
                    <i class="<?php echo esc_attr(get_theme_mod('commercial_automation_services_banner_button_icon', 'fa-solid fa-arrow-right')); ?> ms-2"></i><span class="screen-reader-text"><?php esc_html_e( 'icon','commercial-automation-services');?></span>
                  </a>
                </div>
              <?php }?>
            </div>
          </div>
        </div>
        <div class="col-xl-5">
          <div class="slider-right-mask-img p-0 ">
            <div class="sider-right-inn">
              <div class="right-innner-img">
              <?php if(get_theme_mod('commercial_automation_services_service_banner_player_image') != '') {?>
                <div class="banner-player">
                  <img src="<?php echo esc_url(get_theme_mod('commercial_automation_services_service_banner_player_image')); ?>" alt="" />
                </div>
              <?php }?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
  <div class="temperature">
    <div class="temp-img">
      <?php if(get_theme_mod('commercial_automation_services_whether_image') != '') {?>
       <img src="<?php echo esc_url(get_theme_mod('commercial_automation_services_whether_image')); ?>" alt="" />
      <?php }?>
    </div>
  <?php if(get_theme_mod('commercial_automation_services_whether_text') != '') {?>
    <h2 class="temperature-text"><?php echo esc_html(get_theme_mod('commercial_automation_services_whether_text')); ?>
    <?php
      $commercial_automation_services_temperature_unit = get_theme_mod('commercial_automation_services_temperature_unit', 'celsius');
      if ($commercial_automation_services_temperature_unit === 'celsius') {
          echo esc_html ('°C', 'commercial-automation-services');
      } elseif ($commercial_automation_services_temperature_unit === 'fahrenheit') {
          echo esc_html('°F', 'commercial-automation-services');
      }
    ?>
   </h2>
  <?php }?>
</div>
<?php do_action('commercial_automation_services_after_banner'); ?>

<!-- Product Section -->
<?php if(get_theme_mod('commercial_automation_services_product_settings') != '') {?>
  <section id="main-product" class="pb-5 wow bounceInRight delay-1000" data-wow-duration="3s"> 
    <div class="container">
      <div class="heding-title text-center">
        <?php if( get_theme_mod('commercial_automation_services_product_top_heading_product') != ''){ ?>
          <span class="product-small-heading text-center"><?php echo esc_html(get_theme_mod('commercial_automation_services_product_top_heading_product'));?></span>
        <?php }?>
        <?php if( get_theme_mod('commercial_automation_services_product_heading_product') != ''){ ?>
          <h3 class="product-large-heading text-center"><?php echo esc_html(get_theme_mod('commercial_automation_services_product_heading_product'));?></h3>
        <?php }?>
        <?php if( get_theme_mod('commercial_automation_services_product_title') != ''){ ?>
          <p class="product-large-paragraph text-center"><?php echo esc_html(get_theme_mod('commercial_automation_services_product_title'));?></p>
        <?php }?>
      </div> 
      <div class="owl-carousel"> 
        <?php if ( class_exists( 'WooCommerce' )) {?>
          <?php $args = array( 
            'post_type' => 'product',
            'product_cat' => get_theme_mod('commercial_automation_services_product_settings'),
            'order' => 'ASC',
            'taxonomy'   => 'product_cat',
            'hide_empty' => false, 
          );
          $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
              <div class="item-product">
                <div class="product-cricket">
                  <div class="product-image">
                    <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.esc_url(woocommerce_placeholder_img_src()).'" />'; ?>
                    <?php if (class_exists('YITH_WCWL')): ?>
                      <div class="yith-wcwl-add-to-wishlist">
                        <?php echo do_shortcode('[yith_wcwl_add_to_wishlist]'); ?>
                      </div>
                    <?php endif; ?>
                  </div>
                  <?php 
                  $commercial_automation_services_product_categories = get_the_terms( get_the_ID(), 'product_cat' );
                    if ( $commercial_automation_services_product_categories ) {
                        foreach ( $commercial_automation_services_product_categories as $category ) {
                            echo '<div class="box-para"><a href="' . get_term_link( $category ) . '">' . $category->name . '</a></div>';
                        }
                    }?>
                    <h4 class=""><a href="<?php echo esc_url(get_permalink( $loop->post->ID )); ?>"><?php the_title(); ?></a></h4>
                    <div class="row price-text3">
                      <?php if ( $product->is_type( 'simple' ) ) : ?>
                        <?php if ( $product->get_rating_count() > 0 ) : ?>
                          <div class="col-xl-6 col-6 align-self-center price-text1">
                            <span class="d-flex align-items-center gap-2 product-star-ratings">
                              <?php woocommerce_template_loop_rating( $loop->post, $product ); ?>
                              <?php $rating_count = $product->get_rating_count(); ?>
                              <span class="star-rating-count"> (<?php echo esc_html( $rating_count ); ?>)</span>
                            </span>
                          </div>
                          <div class="col-xl-6 col-6 align-self-center price-text ">
                            <p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price text-end' ) ); ?>">
                              <span class="product-text-selling "><?php echo esc_html(get_theme_mod('commercial_automation_services_product_text',''));?></span>
                              <?php echo $product->get_price_html(); ?>
                            </p>
                          </div>
                        <?php else : ?>
                          <div class="col-xl-12">
                            <p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>">
                              <span class="product-text-selling1 text-start"><?php echo esc_html(get_theme_mod('commercial_automation_services_product_text',''));?></span>
                              <?php echo $product->get_price_html(); ?>
                            </p>
                          </div>
                        <?php endif; ?>
                      <?php endif; ?>
                    </div>
                   <?php if( $product->is_type( 'simple' ) ){ woocommerce_template_loop_add_to_cart( $loop->post, $product ); } ?>
                </div>
              </div>
          <?php endwhile; wp_reset_postdata(); ?> 
        <?php } ?> 
      </div>
    </div> 
  </section>
<?php }?>
<?php do_action( 'commercial_automation_services_product_settings' ); ?>

<!-- Offer Section -->
<section id="offer-section">
  <div class="container">
    <div class="row">
      <div class="col-xl-8 col-lg-8 col-md-12 align-self-center">
        <?php if( get_theme_mod('commercial_automation_services_offer_image') != ''){ ?>
          <div class="row offer-col1">
            <div class="col-xl-5 col-lg-5 col-md-5 align-self-center">
              <?php if( get_theme_mod('commercial_automation_services_offer_small_text') != ''){ ?>
                <span class="offer-small-text"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_small_text'));?></span>
              <?php }?>
              <?php if( get_theme_mod('commercial_automation_services_offer_heading') != ''){ ?>
                <h5 class="offer-heading"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_heading'));?></h5>
              <?php }?>
              <?php if( get_theme_mod('commercial_automation_services_offer_title') != ''){ ?>
                <p class="offer-para"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_title'));?></p>
              <?php }?>
              <?php if( get_theme_mod('commercial_automation_services_product_clock_timer_end') != ''){ ?>
                <div class="countdowntimer">
                  <p id="timer" class="countdown">
                    <?php
                    $commercial_automation_services_dateday = get_theme_mod('commercial_automation_services_product_clock_timer_end'); ?>
                    <input type="hidden" class="date" value="<?php echo esc_html($commercial_automation_services_dateday); ?>"></p>
                </div> 
              <?php }?>
              <div class="d-flex align-items-center gap-4 offer-col1-count">
                <?php if ( get_theme_mod('commercial_automation_services_shop_button_text') != '' || get_theme_mod('commercial_automation_services_shop_small_title_icon') != '' || get_theme_mod('commercial_automation_services_shop_btn_link') != '') {?>
                  <div class ="shop-more">
                    <a href="<?php echo esc_url(get_theme_mod('commercial_automation_services_shop_btn_link',false));?>"><?php echo esc_html(get_theme_mod('commercial_automation_services_shop_button_text'));?>
                      <i class="<?php echo esc_attr(get_theme_mod('commercial_automation_services_shop_small_title_icon', 'fa-solid fa-arrow-right')); ?> ms-2"></i><span class="screen-reader-text"><?php esc_html_e( 'icon','commercial-automation-services');?></span>
                    </a>
                  </div>
                <?php }?>
                <div class="d-flex align-items-center gap-2">
                  <?php if( get_theme_mod('commercial_automation_services_shop_count') != ''){ ?>
                    <span class="shop_count_percent"><?php echo esc_html(get_theme_mod('commercial_automation_services_shop_count'));?></span>
                    <div class="per-off">
                      <span class="percent-text"><?php echo esc_html(get_theme_mod('commercial_automation_services_per_count'));?></span>
                      <span class="off-text"><?php echo esc_html(get_theme_mod('commercial_automation_services_off_count'));?></span>
                    </div>
                  <?php }?>
                </div>
              </div>
            </div>
            <div class="col-xl-7 col-lg-7 col-md-7 text-center align-self-center">
              <div class="shop-img">
                <img src="<?php echo esc_url(get_theme_mod('commercial_automation_services_offer_image')); ?>" alt="" />
              </div>
            </div>
          </div>
        <?php }?>
      </div>
      <div class="col-xl-4 col-lg-4 col-md-12 align-self-center pt-lg-0 pt-md-4">
        <?php if( get_theme_mod('commercial_automation_services_offer_image1') != ''){ ?>
          <div class="shop-col2">
            <?php if( get_theme_mod('commercial_automation_services_offer_small_text1') != ''){ ?>
              <span class="offer-small-text1"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_small_text1'));?></span>
            <?php }?>
            <?php if( get_theme_mod('commercial_automation_services_offer_heading1') != ''){ ?>
              <h6 class="offer-heading1"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_heading1'));?></h6>
            <?php }?>
            <?php if( get_theme_mod('commercial_automation_services_offer_title1') != ''){ ?>
              <p class="offer-para1"><?php echo esc_html(get_theme_mod('commercial_automation_services_offer_title1'));?></p>
            <?php }?>
            <div class="d-flex gap-4 offer-col2">
               <?php if ( get_theme_mod('commercial_automation_services_shop_button_text1') != '' || get_theme_mod('commercial_automation_services_shop_small_title_icon1') != '' || get_theme_mod('commercial_automation_services_shop_btn_link1') != '') {?>
                <div class ="shop-more1">
                  <a href="<?php echo esc_url(get_theme_mod('commercial_automation_services_shop_btn_link1',false));?>"><?php echo esc_html(get_theme_mod('commercial_automation_services_shop_button_text1'));?>
                    <i class="<?php echo esc_attr(get_theme_mod('commercial_automation_services_shop_small_title_icon1', 'fa-solid fa-arrow-right')); ?> ms-2"></i><span class="screen-reader-text"><?php esc_html_e( 'icon','commercial-automation-services');?></span>
                  </a>
                </div>
              <?php }?>
              <div class="shop-img1">
                <img src="<?php echo esc_url(get_theme_mod('commercial_automation_services_offer_image1')); ?>" alt="" />
              </div>
            </div>
          </div>
        <?php }?>
      </div>
    </div>
  </div>
</section>

  <div id="content-vw" class="entry-content pt-5">
    <div class="container">
      <?php while (have_posts()) : the_post(); ?>
        <?php the_content(); ?>
      <?php endwhile; // end of the loop. 
      ?>
    </div>
  </div>
  
</main>

<?php get_footer(); ?> 