<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Prodigy\Includes\Helpers\Prodigy_Formatting;

?>


<input type="hidden" id="is_show_price_sale_format-js" value="<?php echo esc_attr( $is_show_price_sale_format ); ?>">
<div class="prodigy-product__main-price">
	<span class="prodigy-product-list__item-price-default-js prodigy-product-list__item-price--sale"></span>
	<span class="prodigy-product-list__item-price-default-js prodigy-product-list__item-price-js"></span>
	<span class="prodigy-product-list__item-price-default-js">
		<?php if ( ! $is_tiered_prices ) : ?>
			<?php
			if ( isset( $main_price['range'] ) && $main_price['range']['min_price'] !== $main_price['range']['max_price'] ) :
				?>
				<?php if ( $show_min_price ) : ?>
				<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['range']['min_price'] ) ); ?></span>
			<?php else : ?>
				<span class="range-price-js">
						<?php esc_html_e( 'From', 'prodigy-commerce' ); ?>
						<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['range']['min_price'] ) ); ?></span>
							<?php esc_html_e( 'to', 'prodigy-commerce' ); ?>
						<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['range']['max_price'] ) ); ?></span>
					</span>
			<?php endif; ?>
			<?php elseif ( ! $is_single_variants_option && $is_variants && isset( $main_price['sale-price'] ) && $main_price['sale-price'] !== '' ) : ?>
				<span class="prodigy-product-list__item-price--sale"><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['price'] ) ); ?></span>
				<span class="prodigy-product-list__item-price-js"><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['sale-price'] ) ); ?></span>
			<?php elseif ( ! $is_single_variants_option && $is_variants && isset( $main_price['price'] ) ) : ?>
				<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['price'] ) ); ?></span>
			<?php elseif ( $is_tiered_prices && isset( $tiered_price_range['min_price'], $tiered_price_range['max_price'] ) ) : ?>
				<?php if ( $tiered_price_range['min_price'] !== $tiered_price_range['max_price'] ) : ?>
					<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['min_price'] ) ); ?></span>
				<?php else : ?>
					<?php if ( $show_min_price ) : ?>
						<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $main_price['range']['min_price'] ) ); ?></span>
					<?php else : ?>
						<span class="range-price-js">
							<?php esc_html_e( 'From', 'prodigy-commerce' ); ?>
							<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['min_price'] ) ); ?></span>
								<?php esc_html_e( 'to', 'prodigy-commerce' ); ?>
							<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['max_price'] ) ); ?></span>
						</span>
					<?php endif; ?>
				<?php endif; ?>
			<?php endif; ?>
		<?php else : ?>
			<?php if ( ! $is_single_variants_option && isset( $tiered_price_range['min_price'], $tiered_price_range['max_price'] ) ) : ?>
				<?php if ( $tiered_price_range['min_price'] === $tiered_price_range['max_price'] ) : ?>
				<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['min_price'] ) ); ?></span>
			<?php else : ?>
				<span class="prodigy-product__main-price" style="display: none">
					<?php echo esc_html( get_option( 'pg_currency_type' ) ); ?>
				</span>
				<span class="prodigy-product__main-price main-price-js">
					<?php if ( $show_min_price ) : ?>
						<span>
							<?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['min_price'] ) ); ?>
						</span>
					<?php else : ?>
						<span class="range-price-js">
							<?php esc_html_e( 'From', 'prodigy-commerce' ); ?>
							<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['min_price'] ) ); ?></span>
								<?php esc_html_e( 'to', 'prodigy-commerce' ); ?>
								<span><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $tiered_price_range['max_price'] ) ); ?></span>
						</span>
					<?php endif; ?>
				</span>
			<?php endif; ?>
		<?php endif; ?>
	</span>
	<?php endif; ?>
</div>
