<?php
if ( ! get_theme_mod( 'clothing_marketplace_enable_banner_section', false ) ) {
	return;
}
/**
 * Render Banner Section.
*/ 
$clothing_marketplace_banner_section_sub_heading = get_theme_mod( 'clothing_marketplace_banner_section_sub_heading');
$clothing_marketplace_banner_section_heading = get_theme_mod( 'clothing_marketplace_banner_section_heading');
$clothing_marketplace_banner_section_content = get_theme_mod( 'clothing_marketplace_banner_section_content');
$clothing_marketplace_banner_section_description = get_theme_mod( 'clothing_marketplace_banner_section_description');
$clothing_marketplace_button_label = get_theme_mod( 'clothing_marketplace_banner_button_label_');
$clothing_marketplace_button_link  = get_theme_mod( 'clothing_marketplace_banner_button_link_');
$clothing_marketplace_default_image_url = get_template_directory_uri() . '/resource/img/default1.png';
$clothing_marketplace_banner_section_image = get_theme_mod( 'clothing_marketplace_banner_section_image', $clothing_marketplace_default_image_url );

$clothing_marketplace_discount      = get_theme_mod( 'clothing_marketplace_banner_discount');
$clothing_marketplace_discount_lbl  = get_theme_mod( 'clothing_marketplace_banner_discount_label');
$clothing_marketplace_discount_off  = get_theme_mod( 'clothing_marketplace_banner_discount_off');
$clothing_marketplace_bottom_text   = get_theme_mod( 'clothing_marketplace_banner_bottom_text');

$clothing_marketplace_banner_image_alt = '';
$clothing_marketplace_banner_image_id  = attachment_url_to_postid( $clothing_marketplace_banner_section_image );

if ( $clothing_marketplace_banner_image_id ) {
	$clothing_marketplace_banner_image_alt = get_post_meta( $clothing_marketplace_banner_image_id, '_wp_attachment_image_alt', true );
}

if ( empty( $clothing_marketplace_banner_image_alt ) ) {
	$clothing_marketplace_banner_image_alt = $clothing_marketplace_banner_section_heading;
}
?>
<section id="clothing_marketplace_banner_section" class="fashion-banner sale-banner">
	<div class="asterthemes-wrapper">
		<div class="sale-banner__inner">

			<div class="middle-broad-line">
				<span class="sale-banner__stripes" aria-hidden="true"></span>
				<span class="sale-banner__stripes-middle" aria-hidden="true"></span>
				<span class="sale-banner__discount-stripes" aria-hidden="true"></span>
			</div>

			<div class="sale-banner__content banner-content">
				<?php if ( ! empty( $clothing_marketplace_banner_section_sub_heading ) ) : ?>
					<span class="sale-banner__offer offer-text"><?php echo esc_html( $clothing_marketplace_banner_section_sub_heading ); ?></span>
				<?php endif; ?>

				<?php if ( ! empty( $clothing_marketplace_banner_section_heading ) ) : ?>
					<h1 class="sale-banner__heading sale-title"><?php echo esc_html( $clothing_marketplace_banner_section_heading ); ?></h1>
				<?php endif; ?>

				<?php if ( ! empty( $clothing_marketplace_banner_section_content ) ) : ?>
					<div class="sale-banner__subtitle-wrap">
						<h3 class="sale-banner__subtitle sale-subtitle"><?php echo esc_html( $clothing_marketplace_banner_section_content ); ?></h3>
					</div>
				<?php endif; ?>

				<?php if ( ! empty( $clothing_marketplace_banner_section_description ) ) : ?>
					<p class="sale-banner__description"><?php echo esc_html( $clothing_marketplace_banner_section_description ); ?></p>
				<?php endif; ?>

				<?php if ( ! empty( $clothing_marketplace_button_label ) ) : ?>
					<a href="<?php echo esc_url( $clothing_marketplace_button_link ); ?>" class="sale-banner__button banner-btn">
						<?php echo esc_html( $clothing_marketplace_button_label ); ?>
					</a>
				<?php endif; ?>
			</div>

			<div class="sale-banner__model banner-model">
				<img src="<?php echo esc_url( $clothing_marketplace_banner_section_image ); ?>" alt="<?php echo esc_attr( $clothing_marketplace_banner_image_alt ); ?>" loading="eager" decoding="async" fetchpriority="high">
			</div>

			<div class="sale-banner__visual">
				<div class="sale-banner__discount banner-discount">
					<?php if ( ! empty( $clothing_marketplace_discount_lbl ) ) : ?>
						<span class="sale-banner__discount-label"><?php echo esc_html( $clothing_marketplace_discount_lbl ); ?></span>
					<?php endif; ?>

					<?php if ( ! empty( $clothing_marketplace_discount ) ) : ?>
						<h2 class="sale-banner__discount-value"><?php echo esc_html( $clothing_marketplace_discount ); ?></h2>
					<?php endif; ?>

					<?php if ( ! empty( $clothing_marketplace_discount_off ) ) : ?>
						<p class="sale-banner__discount-off"><?php echo esc_html( $clothing_marketplace_discount_off ); ?></p>
					<?php endif; ?>
				</div>
			</div>
		</div>
		
	</div>
	<div class="sale-banner__bottom banner-bottom-strip">
		<p><?php echo esc_html( $clothing_marketplace_bottom_text ); ?></p>
	</div>
</section>