<?php
$bosa_yoga_categoryproductoneID = get_theme_mod( 'bosa_yoga_product_image_one', '' );
$bosa_yoga_categoryproductone = get_theme_mod( 'bosa_yoga_product_category_one', '' );

$bosa_yoga_categoryproducttwoID = get_theme_mod( 'bosa_yoga_product_image_two', '' );
$bosa_yoga_categoryproducttwo = get_theme_mod( 'bosa_yoga_product_category_two', '' );

$bosa_yoga_categoryproductthreeID = get_theme_mod( 'bosa_yoga_product_image_three', '' );
$bosa_yoga_categoryproductthree = get_theme_mod( 'bosa_yoga_product_category_three', '' );

$bosa_yoga_categoryproductfourID = get_theme_mod( 'bosa_yoga_product_image_four', '' );
$bosa_yoga_categoryproductfour = get_theme_mod( 'bosa_yoga_product_category_four', '' );

$bosa_yoga_categoryproductfiveID = get_theme_mod( 'bosa_yoga_product_image_five', '' );
$bosa_yoga_categoryproductfive = get_theme_mod( 'bosa_yoga_product_category_five', '' );

$bosa_yoga_categoryproductsixID = get_theme_mod( 'bosa_yoga_product_image_six', '' );
$bosa_yoga_categoryproductsix = get_theme_mod( 'bosa_yoga_product_category_six', '' );

$bosa_yoga_categoryproductsevenID = get_theme_mod( 'bosa_yoga_product_image_seven', '' );
$bosa_yoga_categoryproductseven = get_theme_mod( 'bosa_yoga_product_category_seven', '' );

$bosa_yoga_categoryproducteightID = get_theme_mod( 'bosa_yoga_product_image_eight', '' );
$bosa_yoga_categoryproducteight = get_theme_mod( 'bosa_yoga_product_category_eight', '' );

$bosa_yoga_categoryproductnineID = get_theme_mod( 'bosa_yoga_product_image_nine', '' );
$bosa_yoga_categoryproductnine = get_theme_mod( 'bosa_yoga_product_category_nine', '' );


$bosa_yoga_category_product_one_array = array();
$bosa_yoga_category_product_two_array = array();
$bosa_yoga_category_product_three_array = array();
$bosa_yoga_has_product_one = false;
$bosa_yoga_has_product_two = false;
$bosa_yoga_has_product_three = false;
if( !empty( $bosa_yoga_categoryproductoneID ) || !empty( $bosa_yoga_categoryproductone ) ){
	$bosa_yoga_category_product_one = wp_get_attachment_image_src( $bosa_yoga_categoryproductoneID ,'bosa-yoga-1370-550');
 	if ( is_array( $bosa_yoga_category_product_one ) ){
 		$bosa_yoga_has_product_one = true;
   	 	$bosa_yoga_category_products_one = $bosa_yoga_category_product_one[0];
   	 	$bosa_yoga_category_product_one_array['image_one'] ['ID'] = $bosa_yoga_category_products_one;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductone ) ){
 		$bosa_yoga_has_product_one = true;
   	 	$bosa_yoga_category_product_one_array['image_one']['category'] = $bosa_yoga_categoryproductone;	
  	}
}
if( !empty( $bosa_yoga_categoryproducttwoID ) || !empty( $bosa_yoga_categoryproducttwo ) ){
	$bosa_yoga_category_product_two = wp_get_attachment_image_src( $bosa_yoga_categoryproducttwoID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_two ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_products_two = $bosa_yoga_category_product_two[0];
   	 	$bosa_yoga_category_product_two_array['image_two'] ['ID'] = $bosa_yoga_category_products_two;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproducttwo ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_product_two_array['image_two']['category'] = $bosa_yoga_categoryproducttwo;	
  	}
}
if( !empty( $bosa_yoga_categoryproductthreeID ) || !empty( $bosa_yoga_categoryproductthree ) ){
	$bosa_yoga_category_product_three = wp_get_attachment_image_src( $bosa_yoga_categoryproductthreeID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_three ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_products_three = $bosa_yoga_category_product_three[0];
   	 	$bosa_yoga_category_product_two_array['image_three'] ['ID'] = $bosa_yoga_category_products_three;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductthree ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_product_two_array['image_three']['category'] = $bosa_yoga_categoryproductthree;	
  	}
}
if( !empty( $bosa_yoga_categoryproductfourID ) || !empty( $bosa_yoga_categoryproductfour ) ){
	$bosa_yoga_category_product_four = wp_get_attachment_image_src( $bosa_yoga_categoryproductfourID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_four ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_products_four = $bosa_yoga_category_product_four[0];
   	 	$bosa_yoga_category_product_two_array['image_four'] ['ID'] = $bosa_yoga_category_products_four;	 	
  	}
  	if ( !empty($bosa_yoga_categoryproductfour) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_product_two_array['image_four']['category'] = $bosa_yoga_categoryproductfour;	
  	}
}
if( !empty( $bosa_yoga_categoryproductfiveID ) || !empty( $bosa_yoga_categoryproductfive ) ){
	$bosa_yoga_category_product_five = wp_get_attachment_image_src( $bosa_yoga_categoryproductfiveID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_five ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_products_five = $bosa_yoga_category_product_five[0];
   	 	$bosa_yoga_category_product_two_array['image_five'] ['ID'] = $bosa_yoga_category_products_five;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductfive ) ){
 		$bosa_yoga_has_product_two = true;
   	 	$bosa_yoga_category_product_two_array['image_five']['category'] = $bosa_yoga_categoryproductfive;	
  	}
}
if( !empty( $bosa_yoga_categoryproductsixID ) || !empty( $bosa_yoga_categoryproductsix ) ){
	$bosa_yoga_category_product_six = wp_get_attachment_image_src( $bosa_yoga_categoryproductsixID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_six ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_products_six = $bosa_yoga_category_product_six[0];
   	 	$bosa_yoga_category_product_three_array['image_six'] ['ID'] = $bosa_yoga_category_products_six;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductsix ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_product_three_array['image_six']['category'] = $bosa_yoga_categoryproductsix;	
  	}
}
if( !empty( $bosa_yoga_categoryproductsevenID ) || !empty( $bosa_yoga_categoryproductseven ) ){
	$bosa_yoga_category_product_seven = wp_get_attachment_image_src( $bosa_yoga_categoryproductsevenID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_seven ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_products_seven = $bosa_yoga_category_product_seven[0];
   	 	$bosa_yoga_category_product_three_array['image_seven'] ['ID'] = $bosa_yoga_category_products_seven;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductseven ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_product_three_array['image_seven']['category'] = $bosa_yoga_categoryproductseven;	
  	}
}
if( !empty( $bosa_yoga_categoryproducteightID ) || !empty( $bosa_yoga_categoryproducteight ) ){
	$bosa_yoga_category_product_eight = wp_get_attachment_image_src( $bosa_yoga_categoryproducteightID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_eight ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_products_eight = $bosa_yoga_category_product_eight[0];
   	 	$bosa_yoga_category_product_three_array['image_eight'] ['ID'] = $bosa_yoga_category_products_eight;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproducteight ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_product_three_array['image_eight']['category'] = $bosa_yoga_categoryproducteight;	
  	}
}
if( !empty( $bosa_yoga_categoryproductnineID ) || !empty( $bosa_yoga_categoryproductnine ) ){
	$bosa_yoga_category_product_nine = wp_get_attachment_image_src( $bosa_yoga_categoryproductnineID ,'bosa-yoga-420-300');
 	if ( is_array( $bosa_yoga_category_product_nine ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_products_nine = $bosa_yoga_category_product_nine[0];
   	 	$bosa_yoga_category_product_three_array['image_nine'] ['ID'] = $bosa_yoga_category_products_nine;	 	
  	}
  	if ( !empty( $bosa_yoga_categoryproductnine ) ){
 		$bosa_yoga_has_product_three = true;
   	 	$bosa_yoga_category_product_three_array['image_nine']['category'] = $bosa_yoga_categoryproductnine;	
  	}
}

$bosa_yoga_product_cat = bosa_yoga_get_post_categories();

if( !get_theme_mod( 'bosa_yoga_disable_product_category_section', true ) && ( $bosa_yoga_has_product_one || $bosa_yoga_has_product_two || $bosa_yoga_has_product_three || get_theme_mod( 'bosa_yoga_product_category_title_one' ) || get_theme_mod( 'bosa_yoga_product_category_title_two' ) || get_theme_mod( 'bosa_yoga_product_category_title_three' ) ) ){ ?>
	<section class="section-product-category-area">
		<div class="row">
			<?php if( $bosa_yoga_has_product_one || get_theme_mod( 'bosa_yoga_product_category_title_one' ) ){ ?>
				<div class="col-md-12 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_yoga_product_category_title_one' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_yoga_product_category_title_one' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_yoga_category_product_one_array as $bosa_yoga_each_categoryproductone ){ ?>
									<div class="col-sm-12">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_yoga_each_categoryproductone['ID'] ) && !empty( $bosa_yoga_each_categoryproductone['ID'] ) ){
												$bosa_yoga_cat_url = '';
												if( isset( $bosa_yoga_each_categoryproductone['category'] ) && !empty( $bosa_yoga_each_categoryproductone['category'] ) ) {
													$bosa_yoga_cat_url = $bosa_yoga_each_categoryproductone['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_yoga_each_categoryproductone['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_yoga_each_categoryproductone['category'] ) && !empty( $bosa_yoga_each_categoryproductone['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_each_categoryproductone ['category'] ) ); ?>">
														<?php echo esc_html($bosa_yoga_product_cat[$bosa_yoga_each_categoryproductone['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_yoga_has_product_two || get_theme_mod( 'bosa_yoga_product_category_title_two' ) ){ ?>
				<div class="col-md-6 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_yoga_product_category_title_two' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_yoga_product_category_title_two' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row flex-row-container">
								<?php foreach( $bosa_yoga_category_product_two_array as $bosa_yoga_each_categoryproducttwo ){ ?>
									<div class="col-sm-6 px-lg-2 flex-col-container">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_yoga_each_categoryproducttwo['ID'] ) && !empty( $bosa_yoga_each_categoryproducttwo['ID'] ) ){
												$bosa_yoga_cat_url = '';
												if( isset( $bosa_yoga_each_categoryproducttwo['category'] ) && !empty( $bosa_yoga_each_categoryproducttwo['category'] ) ) {
													$bosa_yoga_cat_url = $bosa_yoga_each_categoryproducttwo['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_yoga_each_categoryproducttwo['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_yoga_each_categoryproducttwo['category'] ) && !empty( $bosa_yoga_each_categoryproducttwo['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_each_categoryproducttwo ['category'] ) ); ?>">
														<?php echo esc_html($bosa_yoga_product_cat[$bosa_yoga_each_categoryproducttwo['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_yoga_has_product_three || get_theme_mod( 'bosa_yoga_product_category_title_three' ) ){ ?>
				<div class="col-md-6 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_yoga_product_category_title_three' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_yoga_product_category_title_three' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row flex-row-container">
								<?php foreach( $bosa_yoga_category_product_three_array as $bosa_yoga_each_categoryproductthree ){ ?>
									<div class="col-sm-6 px-lg-2 flex-col-container">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_yoga_each_categoryproductthree['ID'] ) && !empty( $bosa_yoga_each_categoryproductthree['ID'] ) ){
												$bosa_yoga_cat_url = '';
												if( isset( $bosa_yoga_each_categoryproductthree['category'] ) && !empty( $bosa_yoga_each_categoryproductthree['category'] ) ) {
													$bosa_yoga_cat_url = $bosa_yoga_each_categoryproductthree['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_yoga_each_categoryproductthree['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_yoga_each_categoryproductthree['category'] ) && !empty( $bosa_yoga_each_categoryproductthree['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_yoga_each_categoryproductthree ['category'] ) ); ?>">
														<?php echo esc_html($bosa_yoga_product_cat[$bosa_yoga_each_categoryproductthree['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</section>
<?php }
