<?php

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

get_header(); ?>

<?php
	global $prof_default;
	$sentient_breadcrumb_text = __("You are here: ","sentient");
	if(of_get_option('select_breadcrumb_position',$prof_default) == 'Right') {$breadcrumbPosition = '';} else {$breadcrumbPosition = 'breadcrumb-left';}	
?>

<?php if(of_get_option('select_breadcrumb',$prof_default) == 'On'){ ?>
	<div class="homepage-container-design  homepage-container-design-top sentient-page-title-container">
		<div class="homepage-container-design-inner">
			<span class="sentient-page-title-text <?php echo $breadcrumbPosition; ?>"><?php woocommerce_page_title(); ?></span>
			<span class="sentient-page-breadcrumb-text <?php echo $breadcrumbPosition; ?>"><span class="sentient-page-breadcrumb-text-colored"><?php echo esc_attr($sentient_breadcrumb_text); ?></span><?php woocommerce_breadcrumb(); ?></span>
		</div>
	</div>
<?php } ?>

<?php

	if(of_get_option('shop_layout',$prof_default) == 'With Sidebar'){ ?>
	
		<div class="page-main-container page-main-container-blog <?php echo $textstyle; ?>">
			 <div class="middle-container blog-middle-container blog-right-sidebar">
			
				<div class="sentient-woocommerce-shop-container">
					<?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 if ( have_posts() ) : ?>

						<?php
							/**
							 * woocommerce_before_shop_loop hook
							 *
							 * @hooked woocommerce_result_count - 20
							 * @hooked woocommerce_catalog_ordering - 30
							 */
							do_action( 'woocommerce_before_shop_loop' );
						?>

						<?php woocommerce_product_loop_start(); ?>

							<?php woocommerce_product_subcategories(); ?>

							<?php while ( have_posts() ) : the_post(); ?>

								<?php wc_get_template_part( 'content', 'product' ); ?>

							<?php endwhile; // end of the loop. ?>

						<?php woocommerce_product_loop_end(); ?>

						<?php
							/**
							 * woocommerce_after_shop_loop hook
							 *
							 * @hooked woocommerce_pagination - 10
							 */
							do_action( 'woocommerce_after_shop_loop' );
						?>

					<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

						<?php wc_get_template( 'loop/no-products-found.php' ); ?>

					<?php endif; ?>
				
					<?php
						global $wp_query;
						$sentient_pagination = '';
						$sentient_page_text = __("Page","sentient");
						$sentient_of_text = __("of","sentient");
						$total = $wp_query->max_num_pages;
						/*echo $total;*/

						if ( $total > 1 ) {
							if ( !$current_page = get_query_var('paged') ){$current_page = 1;}
							/*echo $current_page;*/
							$sentient_pagination = '<span class="sentient-number-of-pages">' . $sentient_page_text . ' ' . $current_page . ' ' . $sentient_of_text . ' ' . $total . '</span>';
						} else {
							$sentient_pagination = '';
						}
						
						echo $sentient_pagination;
					?>			
				
				</div>
				

				<div class="sidebar-container">
					<?php
						$options = get_post_custom(get_option('woocommerce_shop_page_id'));
						if(isset($options['custom_sidebar']))  
						{  
							$sidebar_choice = $options['custom_sidebar'][0];  
						}  
						else  
						{  
							$sidebar_choice = "default";  
						} 
						
						if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($sidebar_choice) ) :   
							dynamic_sidebar($sidebar_choice);  
						else :  
							/* No widget */  
						endif;
						/*get_sidebar('sidebar.php');*/
						
					?>
				</div>
			<?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>
		</div>		
		
	<?php } else { ?>		
	
		<div class="page-main-container page-full-template">
			<div class="middle-container page-full-sample">
				<div class="sentient-woocommerce-shop-container">
					<?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 if ( have_posts() ) : ?>

						<?php
							/**
							 * woocommerce_before_shop_loop hook
							 *
							 * @hooked woocommerce_result_count - 20
							 * @hooked woocommerce_catalog_ordering - 30
							 */
							do_action( 'woocommerce_before_shop_loop' );
						?>

						<?php woocommerce_product_loop_start(); ?>

							<?php woocommerce_product_subcategories(); ?>

							<?php while ( have_posts() ) : the_post(); ?>

								<?php wc_get_template_part( 'content', 'product' ); ?>

							<?php endwhile; // end of the loop. ?>

						<?php woocommerce_product_loop_end(); ?>

						<?php
							/**
							 * woocommerce_after_shop_loop hook
							 *
							 * @hooked woocommerce_pagination - 10
							 */
							do_action( 'woocommerce_after_shop_loop' );
						?>

					<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

						<?php wc_get_template( 'loop/no-products-found.php' ); ?>

					<?php endif; ?>
				
					<?php
						global $wp_query;
						$sentient_pagination = '';
						$sentient_page_text = __("Page","sentient");
						$sentient_of_text = __("of","sentient");
						$total = $wp_query->max_num_pages;
						/*echo $total;*/

						if ( $total > 1 ) {
							if ( !$current_page = get_query_var('paged') ){$current_page = 1;}
							/*echo $current_page;*/
							$sentient_pagination = '<span class="sentient-number-of-pages">' . $sentient_page_text . ' ' . $current_page . ' ' . $sentient_of_text . ' ' . $total . '</span>';
						} else {
							$sentient_pagination = '';
						}
						
						echo $sentient_pagination;
					?>			
				
				</div>
			</div>
		</div>

	<?php }

?>



<?php get_footer(); ?>