<?php
/* Template Name: Price Filter shortcode */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$idwidget     = $attr_shortcode['idWidget'] ?? '';
$heading_text = $args['heading_price_filter'] ?? 'Price Filter';

?>

<?php if ( $idwidget ) : ?>
<div class="prodigy-filter__main prodigy-filter__main-price prodigy-custom-template">
	<p class="prodigy-filter__title prodigy-filter-title-js"><?php echo esc_attr( $heading_text ); ?></p>
	<p class="prodigy-visually-hidden"><?php esc_html_e( 'You can choose the price range to filter - from minimum to maximum value', 'prodigy-commerce' ); ?></p>
<?php endif; ?>

<div class="price-filter-container-js prodigy-filter__main prodigy-filter__main-price prodigy-filter__price-filter-container prodigy-custom-template">
	<div class="prodigy-filter__item">
		<div class="prodigy-filter__range">
			<label class="prodigy-visually-hidden" for="price-range-input" aria-label="<?php esc_html_e( 'Price range label', 'prodigy-commerce' ); ?>"><?php esc_html_e( 'Price range', 'prodigy-commerce' ); ?></label>
			<input id="price-range-input" aria-label="<?php esc_html_e( 'Price range', 'prodigy-commerce' ); ?>" class="js-range-slider" type="text" name="my_range" value="" data-type="double" data-min="<?php echo esc_attr( $min ?? '' ); ?>" data-max="<?php echo esc_attr( $max ?? '' ); ?>" data-from="<?php echo esc_attr( $min ?? '' ); ?>" data-to="<?php echo esc_attr( $max ?? '' ); ?>">
		</div>
		<form>
			<div class="d-flex justify-content-between mb-16">
				<label for="minprice" aria-label="<?php esc_html_e( 'From minimum price', 'prodigy-commerce' ); ?>" class="d-flex flex-column w-100 mr-16">
					<span class="prodigy-filter__field-label"><?php esc_html_e( 'From', 'prodigy-commerce' ); ?></span>
					<input id="minprice" class="prodigy-filter__field-input prodigy-main-input min-js" />
				</label>
				<label for="maxprice" aria-label="<?php esc_html_e( 'To maximum price', 'prodigy-commerce' ); ?>" class="d-flex flex-column w-100">
					<span class="prodigy-filter__field-label"><?php esc_html_e( 'To', 'prodigy-commerce' ); ?></span>
					<input id="maxprice" class="prodigy-filter__field-input prodigy-main-input max-js" />
				</label>
			</div>
			<div class="prodigy-filter__item-price">
				<button type="submit" data-nonce="<?php echo esc_attr( $filter_nonce ?? '' ); ?>" data-taxonomy="<?php echo esc_attr( $taxonomy ?? '' ); ?>" data-category-type="<?php echo esc_attr( $current_type_category ?? '' ); ?>" class="prodigy-main-button w-100 justify-content-center mt-16 price-filter-submit-js">
					<?php esc_html_e( 'Apply Price', 'prodigy-commerce' ); ?>
				</button>
			</div>
		</form>
	</div>
</div>

<?php if ( $idwidget ) : ?>
	</div>
<?php endif; ?>
