File: /storage/v4513/ivenusin/public_html/wp-content/themes/ivenus/woocommerce.php
<?php
/**
* Default Template for Shop
*/
get_header();
global $post;
$post_title = $post->post_title;
if(is_product_category()) {
$cate = get_queried_object();
$cateID = $cate->term_id;
$catslug = $cate->slug;
$category_parent_id = $cate->parent;
$category_parent = get_term_by( 'id', $category_parent_id, 'product_cat' );
$category_parent_slug = $category_parent->slug;
$prod_cat_id = 'category_'.$cateID;
$banner_section = get_field('banner_section',$prod_cat_id);
$desktop_settings = $banner_section['desktop_settings'];
$mobile_settings = $banner_section['mobile_settings'];
if($catslug!='accessories' && $category_parent_slug!='accessories') { ?>
<!-- hero-start -->
<!-- hero-start -->
<!-- hero-start -->
<!-- hero-start -->
<?php
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => '-1',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id', //This is optional, as it defaults to 'term_id'
'terms' => $cateID,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
)
)
);
$cat_products = new WP_Query($args);
$_pf = new WC_Product_Factory();
?>
<section class="grey-bg grey-bg-c">
<div class="container">
<div class="row">
<div class="col-md-12 pt-3 pb-2">
<h4 class="big-font"><?php single_term_title(); ?></h4>
</div>
</div>
<div class="row">
<?php
if ( $cat_products->have_posts() ) {
while ( $cat_products->have_posts() ) : $cat_products->the_post();
$product_queried_object = get_queried_object();
$product = $_pf->get_product($post->ID);
$attachment_ids = $product->get_gallery_attachment_ids();
$currency_symbol = get_woocommerce_currency_symbol();
$product_to_be_labeled_as_new = get_field('product_to_be_labeled_as_new',$post->ID);
$product_detail_page_link = get_field('product_detail_page_link',$post->ID);
if(!empty($product_detail_page_link)) {
$product_page_link = $product_detail_page_link.'?op='.$post->post_name;
} else {
$product_page_link = get_permalink( $product->ID );
}
$product_buy_link = get_permalink( $product->ID );
$i = 0;
?>
<div class="col-sm-6 col-md-6 col-lg-4">
<div class="product product-2">
<figure class="product-media">
<?php /* if( $product->is_on_sale() ) { ?>
<span class="product-label label-circle label-sale">Sale</span>
<?php } else { */ ?>
<?php if($product_to_be_labeled_as_new == 'Yes') { ?>
<span class="product-label label-circle label-new">New</span>
<?php } ?>
<?php // } ?>
<a href="<?php echo $product_buy_link; ?>">
<?php
$product_featured_image = wp_get_attachment_image_url( $product->get_image_id(),'product-listing-size' );
if(!empty($product_featured_image)) { ?>
<img src="<?php echo $product_featured_image; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image">
<?php }
if(!empty($attachment_ids)) {
foreach( $attachment_ids as $attachment_id ) {
$Original_image_url = wp_get_attachment_image_url( $attachment_id,'product-listing-size' );
if( $i == 0 ) { ?>
<img src="<?php echo $Original_image_url; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image-hover">
<?php }
$i++; }
} else { ?>
<img src="<?php echo $product_featured_image; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image-hover">
<?php } ?>
</a>
<div class="product-action-vertical">
<?php
// echo do_shortcode('[yith_wcwl_add_to_wishlist product_id="'.$post->ID.'" link_classes="btn-product-icon btn-wishlist btn-expandable" already_in_wishslist_text="" browse_wishlist_text="" icon="fal fa-heart"]'); ?>
</div><!-- End .product-action -->
<div class="product-action product-action-dark bg-primary">
<a href="<?php echo $product_page_link; ?>" class="btn-product btn-cart" title="Add to cart"><i class="fal fa-lightbulb-on"></i> <span>More Info</span></a>
<?php echo do_shortcode('[yith_compare_button product="'.$product->ID.'"]'); ?>
<!--<a href="#" class="btn-product btn-compare" title="Compare"><i class="fal fa-exchange"></i> <span>compare</span></a>-->
</div><!-- End .product-action -->
</figure><!-- End .product-media -->
<div class="product-body">
<h3 class="product-title cat-pro-title-minh" title="<?php echo get_the_title($product->ID); ?>"><a href="<?php echo $product_buy_link; ?>"><?php echo get_the_title($product->ID); ?></a></h3><!-- End .product-title -->
<div class="row cat-desc-min-height">
<div class="col-md-12">
<p class="product-desc" title="<?php echo get_the_title($product->ID); ?>">
<?php echo get_field('technical_details',$product->ID); ?>
</p><!-- End .product-description -->
</div>
</div>
<div class="product-price cat-pro-pr-mh">
<?php
if( $product->is_type( 'simple' ) ) {
if( $product->is_on_sale() ) { ?>
<span class="new-price"><?php echo 'Price '.$currency_symbol.number_format($product->get_sale_price()); ?></span>
<span class="old-price"><?php echo $currency_symbol.number_format($product->get_regular_price()); ?></span>
<?php } else { ?>
<span class="new-price"><?php echo 'Price '.$currency_symbol.number_format($product->get_price()); ?></span>
<?php }
} elseif( $product->is_type( 'variable' ) ){
$reg_price = '';
$variations = $product->get_children();
$reg_prices = array();
$sale_prices = array();
foreach ($variations as $value) {
$single_variation = new WC_Product_Variation($value);
array_push($reg_prices, $single_variation->get_regular_price());
array_push($sale_prices, $single_variation->get_price());
}
sort($reg_prices);
sort($sale_prices);
$min_price = $reg_prices[0];
$max_price = $reg_prices[count($reg_prices)-1];
if($min_price == $max_price) {
$reg_price = wc_price($min_price);
} else {
//$reg_price = wc_format_price_range($min_price, $max_price);
$reg_price = wc_price($min_price);
}
$min_price = $sale_prices[0];
$max_price = $sale_prices[count($sale_prices)-1];
if($min_price == $max_price) {
$sale_price = wc_price($min_price);
} else {
//$sale_price = wc_format_price_range($min_price, $max_price);
$sale_price = wc_price($min_price);
}
if($sale_price != $reg_price){ ?>
<?php if ($min_price <= 2000) { ?>
<span class="new-price"><?php echo 'Pre Book Amount '.$sale_price.'</span>'; ?><?php //echo $sale_price .' <span class="text-danger"> Pre Book Amount </span>'; ?></span>
<?php } else { ?>
<span class="new-price"><?php echo 'Starting From '.$sale_price.'</span>'; ?></span>
<?php } ?>
<span class="old-price"><?php echo 'Starting From '.$reg_price; ?></span>
<?php } else { ?>
<span class="new-price"><?php echo 'Starting From '. $reg_price; ?></span>
<?php }
//echo $product->get_price_html();
} ?>
<p class="text-secondary font-italic">EMI Offers Available*</p>
</div><!-- End .product-price -->
<a href="<?php echo get_permalink( $product->ID ); ?>" class="btn ivenus-solid-btn"><i class="fal fa-shopping-cart"></i> Select</a>
</div><!-- End .product-body -->
</div>
</div>
<?php
endwhile;
} else {
echo _e('<p>Thank you for your interest, but currently there are no products available. Please check back later.</p>');
}
wp_reset_postdata();
?>
</div>
<div class="row">
<div class="col-md-12 small-text">
<?php /* <h1><?php single_term_title(); ?></h1> */ ?>
<?php the_archive_description(); ?>
</div>
</div>
</div>
</section>
<?php /* 1 July <section class="p-0 d-none">
<div class="row no-gutters">
<?php $compare_section = get_field('compare_section',$prod_cat_id);
$section_title = $compare_section['section_title'];
$select_compare_product_id = $compare_section['select_compare_product'];
$hero_image = $compare_section['hero_image'];
$video_thumbnail_image = $compare_section['video_thumbnail_image'];
$video_thumbnail_image_url = $video_thumbnail_image['url'];
$video_youtube_url = $compare_section['video_youtube_url'];
if(!empty($compare_section)) { ?>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="hero-content-wrap">
<div class="hero-content text-center">
<h1 class="mt-5">Compare</h1>
<?php if(!empty($section_title)) { ?>
<h3 class="mt-2 mb-4"><?php echo $section_title; ?></h3>
<?php } ?>
<?php if(!empty($select_compare_product_id)) { ?>
<div class="slider-action-btn">
<?php echo do_shortcode('[yith_compare_button product="'.$select_compare_product_id.'"]'); ?>
<!--<a href="#" class="btn ivenus-solid-btn"><i class="fal fa-exchange"></i> Compare</a>-->
</div>
<?php } ?>
</div>
</div>
<?php if(!empty($hero_image)) { ?>
<div class="hero-product-img pt-3 pb-5 wow fadeInLeft" data-wow-duration="1s" data-wow-delay="1s">
<div class="hero-img-1 no-animation">
<img src="<?php echo $hero_image['url']; ?>" alt="<?php echo $hero_image['alt']; ?>" class="img-responsive">
</div>
</div>
<?php } ?>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="product-intro-video h-100" style="background-image: url('<?php echo $video_thumbnail_image_url; ?>');" data-overlay="dark" data-opacity="5">
<a class="video-play-button popup-video" href="<?php if(!empty($video_youtube_url)) { echo $video_youtube_url; } else { echo '#'; } ?>">
<span></span>
</a>
</div>
</div>
<?php } ?>
</div>
</section> */ ?>
<?php
} elseif($catslug == 'accessoriesss') {
if(isset($desktop_settings)) {
$hero_image = $desktop_settings['hero_image'];
$hero_title = $desktop_settings['hero_title'];
$hero_external_link = $desktop_settings['hero_external_link'];
$hero_sub_title = $desktop_settings['hero_sub_title'];
$buy_now_link = $desktop_settings['buy_now_link'];
$more_info_link = $desktop_settings['more_info_link'];
?>
<!-- hero-start -->
<!-- hero-start -->
<?php } ?>
<?php if (isset($mobile_settings)) {
$hero_image = $mobile_settings['hero_image'];
$hero_title = $mobile_settings['hero_title'];
$hero_external_link = $mobile_settings['hero_external_link'];
$hero_sub_title = $mobile_settings['hero_sub_title'];
$buy_now_link = $mobile_settings['buy_now_link'];
$more_info_link = $mobile_settings['more_info_link'];
?>
<!-- hero-start -->
<?php } ?>
<!-- hero-start -->
<?php
$sargs = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => $cateID,
'taxonomy' => 'product_cat'
);
$accessories_sub_cats = get_categories($sargs);
if(isset($accessories_sub_cats)) { ?>
<section class="accessories-section">
<div class="container-fluid">
<div class="row justify-content-center">
<?php
foreach($accessories_sub_cats as $accessories_sub_cat) {
$accessories_sub_cat_name = $accessories_sub_cat->name;
$accessories_sub_cat_count = $accessories_sub_cat->count;
$accessories_sub_cat_link = get_term_link( $accessories_sub_cat );
$cat_thumbnail_id = get_woocommerce_term_meta( $accessories_sub_cat->term_id, 'thumbnail_id', true );
$accessories_sub_cat_image = wp_get_attachment_url( $cat_thumbnail_id );
?>
<div class="col-md-6 col-lg-4">
<div class="banner banner-cat">
<a href="<?php echo $accessories_sub_cat_link; ?>">
<?php if(!empty($accessories_sub_cat_image)) { ?>
<img src="<?php echo $accessories_sub_cat_image; ?>" alt="<?php echo $accessories_sub_cat_name; ?>">
<?php } else { ?>
<img src="<?php echo THEME_URI; ?>/assets/images/a1.jpg" alt="Default Category Image">
<?php } ?>
</a>
<div class="banner-content">
<h3 class="banner-title"><?php echo $accessories_sub_cat_name; ?></h3><!-- End .banner-title -->
<h4 class="banner-subtitle"><?php echo $accessories_sub_cat_count; ?> Products</h4><!-- End .banner-subtitle -->
<a href="<?php echo $accessories_sub_cat_link; ?>" class="banner-link">Shop Now</a>
</div><!-- End .banner-content -->
</div><!-- End .banner -->
</div><!-- End .col-md-6 -->
<?php } ?>
</div><!-- End .row -->
</div>
</section>
<?php } ?>
<?php } elseif( $category_parent_slug == 'accessories' || $catslug == 'accessories' ) { ?>
<main class="main grey-bg overflow-hidden">
<section class="accessories-section overflow-hidden">
<div class="container-fluid">
<div class="filter-sidebar d-none">
<?php
$dargs = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $cateID,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
'operator' => 'NOT IN'
)
)
);
$accessories_products = new WP_Query($dargs);
$accessories_p = new WC_Product_Factory();
if ( $accessories_products->have_posts() ) {
while ( $accessories_products->have_posts() ) : $accessories_products->the_post();
$a_product_queried_object = get_queried_object();
$product = $accessories_p->get_product($post->ID);
$currency_symbol = get_woocommerce_currency_symbol();
if( $product->is_on_sale() ) {
$prod_price = $product->get_sale_price();
} else {
$prod_price = $product->get_price();
}
if(!empty($prod_price)) {
$prod_price = $prod_price;
} else {
$prod_price = 0;
}
$prod_price_arr[] = $prod_price;
endwhile;
$min_price = min($prod_price_arr);
$max_price = max($prod_price_arr);
} else {
$min_price = 0;
$max_price = 1000;
}
$category_slug = $catslug;
$query_args = array(
'status' => 'publish',
'limit' => -1,
'category' => array( $category_slug ),
);
$data = array();
$datatwo = array();
foreach( wc_get_products($query_args) as $product ){
foreach( $product->get_attributes() as $taxonomy => $attribute ){
$attribute_name = wc_attribute_label( $taxonomy ); // Attribute name
$attribute_taxonomy = get_taxonomy( $taxonomy )->labels->singular_name;
foreach ( $attribute->get_terms() as $term ){
$data[$taxonomy][$term->term_id] = $term->name;
$datatwo[$attribute_name][$term->term_id] = $term->name;
}
}
}
$attributes_keys_arr = array_keys($data);
$attributes_values_arr = array_values($data);
$taxonomy_keys_arr = array_keys($datatwo);
$a = 0;
if(!empty($taxonomy_keys_arr)) { ?>
<div class="cd-filter filter-is-visible">
<script>
var MyAjax = "<?php echo SITE_URL; ?>/wp-admin/admin-ajax.php";
</script>
<form id="accessoriesfilterValidate" name="accessoriesfilterValidate" method="post">
<input id="current_cat_id" name="current_cat_id" value="<?php echo $catslug; ?>" type="hidden"/>
<?php foreach($taxonomy_keys_arr as $taxonomy_key) { ?>
<div class="cd-filter-block" id="prod_block_<?php echo $a; ?>">
<h4><?php echo $taxonomy_key; ?></h4>
<ul class="cd-filter-content cd-filters list" <?php if($a > 0) { ?> style="display: none;" <?php } ?>>
<?php
$v = 1;
foreach($attributes_values_arr[$a] as $attributes_value) { ?>
<li>
<input class="filter" data-filter=".check<?php echo $v.$a.$taxonomy_key; ?>" type="checkbox" id="checkbox<?php echo $v.$a.$taxonomy_key; ?>" name="accessories_checkbox[<?php echo $attributes_keys_arr[$a]; ?>][<?php echo $v.$a.$taxonomy_key; ?>]" value="<?php echo $attributes_value; ?>">
<label class="checkbox-label" for="checkbox<?php echo $v.$a; ?>"><?php echo $attributes_value; ?></label>
</li>
<?php $v++; } ?>
</ul> <!-- cd-filter-content -->
</div>
<?php $a++; } ?>
<div class="cd-filter-block cd_price_block">
<h4 class="closed">Price</h4>
<div class="cd-filter-content cd-filters list" style="display: none;">
<div class="row">
<div class="col-sm-10 offset-sm-1">
<div id="slider-range"></div>
</div>
</div>
<div class="row slider-labels">
<div class="col-6 caption">
<span id="slider-range-value1"></span>
</div>
<div class="col-6 text-right caption">
<span id="slider-range-value2"></span>
</div>
</div>
<div class="row">
<div class="col-sm-10 offset-sm-1">
<input type="hidden" id="min-value" name="min-value" value="">
<input type="hidden" id="max-value" name="max-value" value="">
</div>
</div>
</div> <!-- cd-filter-content -->
</div>
<br/>
<div>
<input type="submit" value="Filter" id="filter_submit" name="filter_submit" class="btn ivenus-solid-btn"/>
<input type="reset" value="Reset" id="filter_reset" name="filter_reset" class="btn ivenus-solid-btn"/>
</div>
</form>
<a href="javascript:void(0);" class="cd-close"><i class="fal fa-times"></i></a>
</div> <!-- cd-filter -->
<a href="javascript:void(0);" class="cd-filter-trigger">Filters</a>
<?php } ?>
</div>
<div class="row">
<div class="col-md-12 pt-3 pb-2">
<h4 class="big-font"><?php single_term_title(); ?></h4>
</div>
</div>
<div class="row">
<?php /* Code for sidebar Amit Disable on 21 June<div class="col-md-2">
<!-- Add Sidebar -->
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
<?php endif; ?>
<!--End Add Sidebar -->
</div> */ ?>
<div class="col-md-12">
<section class="cd-gallery1 grey-bg filter-is-visible p-0">
<?php if ( $accessories_products->have_posts() ) { ?>
<div class="row">
<?php
while ( $accessories_products->have_posts() ) : $accessories_products->the_post();
$a_product_queried_object = get_queried_object();
$product = $accessories_p->get_product($post->ID);
$attachment_ids = $product->get_gallery_attachment_ids();
/*echo '<pre>';
print_r($attachment_ids);
echo '</pre>';*/
$currency_symbol = get_woocommerce_currency_symbol();
$product_to_be_labeled_as_new = get_field('product_to_be_labeled_as_new',$post->ID);
$i = 0 ;
?>
<div class="col-12 col-sm-6 col-md-6 col-lg-3 filterprodiv" id="product_<?php echo $product->get_id(); ?>">
<div class="product product-2">
<figure class="product-media">
<?php if( $product->is_on_sale() ) { ?>
<span class="product-label label-circle label-sale">Sale</span>
<?php } else { ?>
<?php if($product_to_be_labeled_as_new == 'Yes') { ?>
<span class="product-label label-circle label-new">New</span>
<?php } ?>
<?php } ?>
<a href="<?php echo get_permalink( $product->ID ); ?>">
<?php
$product_featured_image = wp_get_attachment_image_url( $product->get_image_id(),'product-listing-size' );
if(!empty($product_featured_image)) { ?>
<img src="<?php echo $product_featured_image; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image">
<?php }
if(!empty($attachment_ids)) {
foreach( $attachment_ids as $attachment_id ) {
$Original_image_url = wp_get_attachment_image_url( $attachment_id,'product-listing-size' );
if( $i == 0 ) { ?>
<img src="<?php echo $Original_image_url; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image-hover">
<?php }
$i++; }
} else { ?>
<img src="<?php echo $product_featured_image; ?>" alt="<?php echo $product->get_title(); ?>" class="product-image-hover">
<?php } ?>
</a>
<div class="product-action-vertical">
<?php
echo do_shortcode('[yith_wcwl_add_to_wishlist product_id="'.$post->ID.'"]'); ?>
</div><!-- End .product-action -->
<div class="product-action product-action-dark d-none">
<a href="<?php echo get_permalink( $product->ID ); ?>" class="btn-product btn-cart" title="Add to cart"><i class="fal fa-lightbulb-on"></i> <span>More Info</span></a>
<?php echo do_shortcode('[yith_compare_button product="'.$product->ID.'"]'); ?>
</div><!-- End .product-action -->
</figure><!-- End .product-media -->
<div class="product-body">
<h3 class="product-title" title="<?php echo get_the_title($product->ID); ?>"><a href="<?php echo get_permalink( $product->ID ); ?>"><?php echo get_the_title($product->ID); ?></a></h3><!-- End .product-title -->
<div class="product-price">
<?php
if( $product->is_type( 'simple' ) ) {
if( $product->is_on_sale() ) {
if($product->get_sale_price()!='') { ?>
<span class="new-price"><?php echo $currency_symbol.number_format($product->get_sale_price()); ?></span>
<span class="old-price"><?php echo $currency_symbol.number_format($product->get_regular_price()); ?></span>
<?php } else { ?>
<span class="new-price"><?php echo 'Out Of Stock'; ?></span>
<?php } ?>
<?php } else {
if($product->get_price()!='') { ?>
<span class="new-price"><?php echo $currency_symbol.number_format($product->get_price()); ?></span>
<?php } else { ?>
<span class="new-price"><?php echo 'Out Of Stock'; ?></span>
<?php }
}
} elseif( $product->is_type( 'variable' ) ){
echo 'Starting From '.$product->get_price_html();
} ?>
</div><!-- End .product-price -->
<?php /* <a href="<?php echo get_permalink( $product->ID ); ?>" class="btn ivenus-solid-btn"><i class="fal fa-shopping-cart"></i> Buy Now</a> */ ?>
<a href="<?php echo get_permalink( $product->ID ); ?>" class="btn ivenus-solid-btn"><i class="fal fa-shopping-cart"></i> SELECT</a>
</div><!-- End .product-body -->
</div>
</div>
<?php endwhile; ?>
<div class="col-12 col-sm-6 col-md-6 col-lg-4 noprodiv" style="display: none;">
<p>No Accssories available for current filters.</p>
</div>
</div>
<?php } else {
echo '<p>No accessories available in this category.</p>';
} ?>
</section>
</div>
</div>
<div class="row">
<div class="col-md-12 small-text">
<?php the_archive_description(); ?>
</div>
</div>
</div>
</section>
</main>
<?php }
} elseif(is_product()) { ?>
<main class="main grey-bg">
<?php woocommerce_content(); ?>
</main>
<?php } else { ?>
<main class="main">
<section>
<div class="col-sm-12">
<?php woocommerce_content(); ?>
</div>
</section>
</main>
<?php } ?>
<div id="preloaderdiv" style="background: url('<?php echo THEME_URI; ?>/assets/images/ajax-loader.gif') 50% 50% no-repeat rgb(249,249,249)"></div>
<script>
jQuery(document).ready(function($){
var category_parent_slug = '<?php echo $category_parent_slug; ?>';
var category_slug = '<?php echo $category_slug; ?>';
/*if(category_parent_slug == 'accessories' || category_slug == 'accessories') {
//open/close lateral filter
$('.cd-filter-trigger').on('click', function(){
triggerFilter(true);
});
$('.cd-filter .cd-close').on('click', function(){
triggerFilter(false);
});
function triggerFilter($bool) {
var elementsToTrigger = $([$('.cd-filter-trigger'), $('.cd-filter'), $('.cd-tab-filter'), $('.cd-gallery')]);
elementsToTrigger.each(function(){
$(this).toggleClass('filter-is-visible', $bool);
});
}
//close filter dropdown inside lateral .cd-filter
$('.cd-filter-block h4').on('click', function(){
$(this).toggleClass('closed').siblings('.cd-filter-content').slideToggle(300);
});
var alterClass = function() {
var ww = document.body.clientWidth;
if (ww < 1025) {
$('.cd-filter').removeClass('filter-is-visible');
$('.cd-gallery').removeClass('filter-is-visible');
} else if (ww >= 1025) {
$('.cd-filter').addClass('filter-is-visible');
$('.cd-gallery').addClass('filter-is-visible');
};
};
$(window).resize(function(){
alterClass();
});
//Fire it when the page first loads:
alterClass();
var min_price = '<?php echo $min_price; ?>';
var max_price = '<?php echo $max_price; ?>';
if( min_price == max_price ) {
min_price = 0;
}
var currency_symbol = '<?php echo $currency_symbol; ?>';
$('.noUi-handle').on('click', function() {
$(this).width(50);
});
var rangeSlider = document.getElementById('slider-range');
var moneyFormat = wNumb({
decimals: 0,
thousand: ',',
prefix: currency_symbol,
});
noUiSlider.create(rangeSlider, {
start: [parseInt(min_price), parseInt(max_price)],
step: 1,
range: {
'min': [parseInt(min_price)],
'max': [parseInt(max_price)]
},
format: moneyFormat,
connect: true
});
// Set visual min and max values and also update value hidden form inputs
rangeSlider.noUiSlider.on('update', function(values, handle) {
document.getElementById('slider-range-value1').innerHTML = values[0];
document.getElementById('slider-range-value2').innerHTML = values[1];
$("#min-value").val(moneyFormat.from(values[0]));
$("#max-value").val(moneyFormat.from(values[1]));
document.getElementsByName('min-value').value = moneyFormat.from(values[0]);
document.getElementsByName('max-value').value = moneyFormat.from(values[1]);
});
var filterAjax = MyAjax + "?action=accessories_filter_action";
$("#filter_reset").on('click',function() {
document.getElementById('accessoriesfilterValidate').reset();
$(".filterprodiv").each(function(){
$(this).show();
});
rangeSlider.noUiSlider.set([parseInt(min_price), parseInt(max_price)]);
});
$("#accessoriesfilterValidate").validate({
submitHandler: function(form) {
var filterformData = new FormData();
var filterCheckboxes = $("input[name='accessories_checkbox[values][]']");
var other_data = $('#accessoriesfilterValidate').serializeArray();
$.each(other_data,function(key,input){
filterformData.append(input.name,input.value);
});
$.ajax({
type: "POST",
url:filterAjax,
contentType: false,
processData: false,
data:filterformData,
beforeSend: function(){
$("#preloaderdiv").show();
},
success:function(response) {
response = JSON.parse(response);
prod_arr = response.productarr;
prod_not_arr = response.productnotarr;
if(response.status == 1) {
$("#preloaderdiv").hide();
for (i = 0; i < prod_not_arr.length; i++) {
$("#product_"+prod_not_arr[i]).hide();
}
for (i = 0; i < prod_arr.length; i++) {
$("#product_"+prod_arr[i]).show();
}
if(prod_arr.length <= 0) {
$(".noprodiv").show();
} else {
$(".noprodiv").hide();
}
} else {
$("#preloaderdiv").hide();
alert(response);
}
}
});
}
});
}*/
});
</script>
<?php get_footer(); ?>