<?php
  // Metabox
  $confin_id    = ( isset( $post ) ) ? $post->ID : 0;
  $confin_id    = ( is_home() ) ? get_option( 'page_for_posts' ) : $confin_id;
  $confin_id    = ( ! is_tag() && ! is_archive() && ! is_search() && ! is_404() && ! is_singular('testimonial') ) ? $confin_id : false;
  $confin_meta  = get_post_meta( $confin_id, 'page_type_metabox', true );

  // Header Style
  if ( $confin_meta ) {
    $confin_header_design  = $confin_meta['select_header_design'];
    $confin_cart_widget = isset( $confin_meta['confin_cart_widget'] ) ? $confin_meta['confin_cart_widget'] : '';
    $confin_search = isset( $confin_meta['confin_search'] ) ? $confin_meta['confin_search'] : '';
  } else {
    $confin_header_design  = cs_get_option( 'select_header_design' );
    $confin_cart_widget  = cs_get_option( 'confin_cart_widget' );
    $confin_search  = cs_get_option( 'confin_search' );
  }
  if ( $confin_header_design === 'default' ) {
    $confin_header_design_actual  = cs_get_option( 'select_header_design' );
  } else {
    $confin_header_design_actual = ( $confin_header_design ) ? $confin_header_design : cs_get_option('select_header_design');
  }
  $confin_header_design_actual = $confin_header_design_actual ? $confin_header_design_actual : 'style_two';

  if ( $confin_meta && $confin_header_design !== 'default') {
   $confin_cart_widget = isset( $confin_meta['confin_cart_widget'] ) ? $confin_meta['confin_cart_widget'] : '';
   $confin_search = isset( $confin_meta['confin_search'] ) ? $confin_meta['confin_search'] : '';
  } else {
    $confin_cart_widget  = cs_get_option( 'confin_cart_widget' );
    $confin_search  = cs_get_option( 'confin_search' );
  }
?>
  <div class="cart-search-contact">
    <?php if ( !$confin_search ) { ?>
      <div class="header-search-form-wrapper">
          <button class="search-toggle-btn"><i class="fi flaticon-search"></i></button>
          <div class="header-search-form">
              <form method="get" class="searchform" action="<?php echo esc_url(home_url('/')); ?>">
                  <div>
                      <input type="text" name="s" id="s" class="form-control" placeholder="<?php echo esc_attr__('Search...','confin'); ?>">
                      <button type="submit"><i class="fi flaticon-search"></i></button>
                  </div>
              </form>
          </div>
      </div>
    <?php }
      if ( $confin_cart_widget &&  class_exists( 'WooCommerce' ) ) {
        get_template_part( 'theme-layouts/header/top','cart' );
      }
    ?>
</div>