<?php
$bosa_yoga_blogAdvertoneID = get_theme_mod( 'bosa_yoga_blog_commercial_image_one','');
$bosa_yoga_blogDiscountoneLabel = get_theme_mod( 'bosa_yoga_discount_label_one', '');
$bosa_yoga_blogAdverttwoID = get_theme_mod( 'bosa_yoga_blog_commercial_image_two','');       
$bosa_yoga_blogDiscounttwoLabel = get_theme_mod( 'bosa_yoga_discount_label_two', '');
$bosa_yoga_blogAdvertthreeID = get_theme_mod( 'bosa_yoga_blog_commercial_image_three','');
$bosa_yoga_blogDiscountthreeLabel = get_theme_mod( 'bosa_yoga_discount_label_three', '');

$bosa_yoga_Advert_array = array();
$bosa_yoga_has_Advert = false;
$bosa_yoga_has_label = false;
if( !empty( $bosa_yoga_blogAdvertoneID ) || !empty( $bosa_yoga_blogDiscountoneLabel ) ){
	$bosa_yoga_blog_advertisement_one  = wp_get_attachment_image_src( $bosa_yoga_blogAdvertoneID,'bosa-yoga-590-310');
 	if ( is_array(  $bosa_yoga_blog_advertisement_one ) ){
 		$bosa_yoga_has_Advert = true;
 		$bosa_yoga_has_label = true;
   	 	$bosa_yoga_blog_advertisements_one = $bosa_yoga_blog_advertisement_one[0];
   	 	$bosa_yoga_Advert_array['image_one'] = array(
			'ID' => $bosa_yoga_blog_advertisements_one,
			'discount_label' => $bosa_yoga_blogDiscountoneLabel,
		);	
  	}
}
if( !empty( $bosa_yoga_blogAdverttwoID  ) || !empty( $bosa_yoga_blogDiscounttwoLabel ) ){
	$bosa_yoga_blog_advertisement_two = wp_get_attachment_image_src( $bosa_yoga_blogAdverttwoID,'bosa-yoga-590-310');
	if ( is_array(  $bosa_yoga_blog_advertisement_two ) ){
		$bosa_yoga_has_Advert = true;
		$bosa_yoga_has_label = true;	
        $bosa_yoga_blog_advertisements_two = $bosa_yoga_blog_advertisement_two[0];
        $bosa_yoga_Advert_array['image_two'] = array(
			'ID' => $bosa_yoga_blog_advertisements_two,
			'discount_label' => $bosa_yoga_blogDiscounttwoLabel,
		);	
  	}
}
if( !empty( $bosa_yoga_blogAdvertthreeID ) || !empty( $bosa_yoga_blogDiscountthreeLabel )){	
	$bosa_yoga_blog_advertisement_three = wp_get_attachment_image_src( $bosa_yoga_blogAdvertthreeID,'bosa-yoga-590-310');
	if ( is_array(  $bosa_yoga_blog_advertisement_three ) ){
		$bosa_yoga_has_Advert = true;
		$bosa_yoga_has_label = true;
      	$bosa_yoga_blog_advertisements_three = $bosa_yoga_blog_advertisement_three[0];
      	$bosa_yoga_Advert_array['image_three'] = array(
			'ID' => $bosa_yoga_blog_advertisements_three,
			'discount_label' => $bosa_yoga_blogDiscountthreeLabel,
		);	
  	}
}

if( !get_theme_mod( 'bosa_yoga_disable_commercial_section', true ) && $bosa_yoga_has_Advert && $bosa_yoga_has_label ){ ?>
	<section class="section-commercial-area">
		<?php foreach( $bosa_yoga_Advert_array as $bosa_yoga_each_Advert ){ ?>
			<article class="commercial-content-wrap">
				<figure class= "featured-image">
					<?php
						if( !empty( $bosa_yoga_each_Advert['discount_label'] ) ) { ?>
							<span class="overlay-txt">
								<?php
									echo esc_html( $bosa_yoga_each_Advert['discount_label'] );
								?>
							</span>
						<?php } ?>
					<img src="<?php echo esc_url( $bosa_yoga_each_Advert['ID'] ); ?>">
				</figure>
			</article>
		<?php } ?>
	</section>
<?php }