<?php
$bosa_logistics_blog_code_imageoneID 	= get_theme_mod( 'bosa_logistics_blog_coupons_image_one','');
$bosa_logistics_blog_code_imagetwoID 	= get_theme_mod( 'bosa_logistics_blog_coupons_image_two','');       
$bosa_logistics_blog_code_imagethreeID  = get_theme_mod( 'bosa_logistics_blog_coupons_image_three','');
$bosa_logistics_blog_code_imagefourID 	= get_theme_mod( 'bosa_logistics_blog_coupons_image_four','');
$bosa_logistics_blog_code_oneID 		= get_theme_mod( 'bosa_logistics_coupons_text_one','');
$bosa_logistics_blog_code_twoID 		= get_theme_mod( 'bosa_logistics_coupons_text_two','');
$bosa_logistics_blog_code_threeID 		= get_theme_mod( 'bosa_logistics_coupons_text_three','');
$bosa_logistics_blog_code_fourID 		= get_theme_mod( 'bosa_logistics_coupons_text_four','');

$bosa_logistics_coupons_array = array();
$bosa_logistics_has_code_img = false;
$bosa_logistics_has_code_txt = false;
if( !empty( $bosa_logistics_blog_code_imageoneID ) ){
	$bosa_logistics_blog_coupon_one  = wp_get_attachment_image_src( $bosa_logistics_blog_code_imageoneID,'bosa-logistics-420-300');
 	if ( is_array(  $bosa_logistics_blog_coupon_one ) ){
 		$bosa_logistics_has_code_img = true;
 		$bosa_logistics_has_code_txt = true;
   	 	$bosa_logistics_blog_coupons_one = $bosa_logistics_blog_coupon_one[0];
   	 	$bosa_logistics_coupons_array['image_one'] = array(
			'ID' => $bosa_logistics_blog_coupons_one,
			'txt' => $bosa_logistics_blog_code_oneID,
		);	
  	}
}
if( !empty( $bosa_logistics_blog_code_imagetwoID ) ){
	$bosa_logistics_blog_coupon_two = wp_get_attachment_image_src( $bosa_logistics_blog_code_imagetwoID,'bosa-logistics-420-300');
	if ( is_array(  $bosa_logistics_blog_coupon_two ) ){
		$bosa_logistics_has_code_img = true;
		$bosa_logistics_has_code_txt = true;	
        $bosa_logistics_blog_coupons_two = $bosa_logistics_blog_coupon_two[0];
        $bosa_logistics_coupons_array['image_two'] = array(
			'ID' => $bosa_logistics_blog_coupons_two,
			'txt' => $bosa_logistics_blog_code_twoID,
		);	
  	}
}
if( !empty( $bosa_logistics_blog_code_imagethreeID ) ){	
	$bosa_logistics_blog_coupon_three = wp_get_attachment_image_src( $bosa_logistics_blog_code_imagethreeID,'bosa-logistics-420-300');
	if ( is_array(  $bosa_logistics_blog_coupon_three ) ){
		$bosa_logistics_has_code_img = true;
		$bosa_logistics_has_code_txt = true;
      	$bosa_logistics_blog_coupons_three = $bosa_logistics_blog_coupon_three[0];
      	$bosa_logistics_coupons_array['image_three'] = array(
			'ID' => $bosa_logistics_blog_coupons_three,
			'txt' => $bosa_logistics_blog_code_threeID,
		);	
  	}
}
if( !empty( $bosa_logistics_blog_code_imagefourID ) ){	
	$bosa_logistics_blog_coupon_four = wp_get_attachment_image_src( $bosa_logistics_blog_code_imagefourID,'bosa-logistics-420-300');
	if ( is_array(  $bosa_logistics_blog_coupon_four ) ){
		$bosa_logistics_has_code_img = true;
		$bosa_logistics_has_code_txt = true;
      	$bosa_logistics_blog_coupons_four = $bosa_logistics_blog_coupon_four[0];
      	$bosa_logistics_coupons_array['image_four'] = array(
			'ID' => $bosa_logistics_blog_coupons_four,
			'txt' => $bosa_logistics_blog_code_fourID,
		);	
  	}
}

if( !get_theme_mod( 'bosa_logistics_disable_coupons_section', false ) && $bosa_logistics_has_code_img && $bosa_logistics_has_code_txt ){ ?>
	<section class="section-coupon-code-area">
		<div class="row">
			<?php foreach( $bosa_logistics_coupons_array as $bosa_logistics_each_coupons ){ ?>
				<div class="col-md-3 col-sm-6">
					<article class="coupon-code-content-wrap">
						<figure class= "featured-image">
							<img src="<?php echo esc_url( $bosa_logistics_each_coupons['ID'] ); ?>">
						</figure>
						<?php if( !empty( $bosa_logistics_each_coupons['txt'] ) ) { ?>
							<div class="coupon-code-txt">
								<?php
									echo esc_html( $bosa_logistics_each_coupons['txt'] );
								?>
							</div>
						<?php } ?>
					</article>
				</div>
			<?php } ?>
		</div>	
	</section>
<?php }