<?php
/**
 * The Template for displaying all single products
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-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://woo.com/document/template-structure/
 * @package     WooCommerce\Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
get_header( 'shop' );
$data    = \INVENTIVE\Includes\Classes\Common::instance()->data( 'single' )->get();

$layout = $data->get( 'layout' );
$sidebar = $data->get( 'sidebar' );

$layout = ( $layout ) ? $layout : 'full';
$sidebar = ( $sidebar ) ? $sidebar : '';

if (is_active_sidebar( $sidebar )) {$layout = 'right';} else{$layout = 'full';}
$class = ( !$layout || $layout == 'full' ) ? 'col-lg-12 col-sm-12 col-md-12' : 'col-sm-12 col-md-12 col-lg-9';

if ( class_exists( '\Elementor\Plugin' ) && $data->get( 'tpl-type' ) == 'e') {
	
	while(have_posts()) {
	   the_post();
	   the_content();
    }

} else {
?>

<?php if ( class_exists( '\Elementor\Plugin' )):?>
	<?php do_action( 'inventive_banner', $data );?>
<?php else:?>
<!-- page-title -->
<section class="page-title">
    <div class="bg-layer" style="background-image: url('<?php echo esc_url( $data->get( 'banner' ) ); ?>');"></div>
    <div class="auto-container">
        <div class="content-box">
            <h1><?php if( $data->get( 'title' ) ) echo wp_kses( $data->get( 'title' ), true ); else( the_title( ) ); ?></h1>
            <ul class="bread-crumb clearfix">
                <?php echo inventive_the_breadcrumb(); ?>
            </ul>
        </div>
    </div>
</section>
<!-- page-title end -->
<?php endif;?>

<!-- shop-details -->
<section class="shop-details pt_100 pb_70 te-shop__detail">
    <div class="auto-container">
        <div class="shop-details-content">
            <div class="row clearfix">
               
                <!-- sidebar area -->
				<?php if( $data->get( 'layout' ) == 'left' ): ?>
                <!--Start Thm Sidebar Box-->
                <div class="col-xl-4 sidebar-side left">
                    <div class="thm-sidebar-box">
                        <?php dynamic_sidebar( $sidebar ); ?>
                    </div>
                </div>
                <?php endif; ?>
                <!-- sidebar area -->
                
                <!-- sidebar area -->         
                <div class="<?php echo esc_attr($class); ?> <?php if ( $data->get( 'layout' ) == 'left' ) echo 'left-sidebar'; elseif ( $data->get( 'layout' ) == 'right' ) echo 'right-sidebar'; ?>">
                    <?php
                        /**
						 * woocommerce_before_main_content hook.
						 *
						 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
						 * @hooked woocommerce_breadcrumb - 20
						 */
                        do_action( 'woocommerce_before_main_content' );
                    ?>
                        <?php while ( have_posts() ) : the_post(); ?>
                            <?php wc_get_template_part( 'content', 'single-product' ); ?>
                        <?php endwhile; // end of the loop. ?>
                    <?php
                       /**
					 * 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( $data->get( 'layout' ) == 'right' ): ?>
                <!--Start Thm Sidebar Box-->
                <div class="col-lg-3 col-md-12 col-sm-12 sidebar-side">
                    <div class="shop-sidebar">
                        <?php dynamic_sidebar( $sidebar ); ?>
                    </div>
                </div>
                <?php endif; ?>
                <!-- sidebar area -->
                
            </div>		
        </div>
	</div>
</section>
<?php
}
get_footer( 'shop' );


/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
