Home New Guten › Forums › WoodMart support forum › Price Filter Widget – Clear All Button
Price Filter Widget – Clear All Button
- This topic has 1 reply, 2 voices, and was last updated 6 years ago by
Artem Temos.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
August 13, 2019 at 10:41 am #137899
newsprinceParticipant@XTEMOS Team
Please enable also when someone is filtering via the price or price range widget to show them the Clear all button.
Currently when you filter with price the clear all button is not enabled afterwards.
Consider adding the following code to enable it.
/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php
/** * ------------------------------------------------------------------------------------------------ * Clear all filters button * ------------------------------------------------------------------------------------------------ */ if( ! function_exists( 'woodmart_clear_filters_btn' ) ) { function woodmart_clear_filters_btn() { if ( ! woodmart_woocommerce_installed() ) { return; } global $wp; $url = home_url( add_query_arg( array( $_GET ), $wp->request ) ); $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); $min_price = isset($_GET['min_price']) ? wc_clean($_GET['min_price']) : 0; $max_price = isset($_GET['max_price']) ? wc_clean($_GET['max_price']) : 0; if ( 0 < count( $_chosen_attributes ) || 0 < $min_price || 0 < $max_price) { $reset_url = strtok( $url, '?' ); if ( isset( $_GET['post_type'] ) ) $reset_url = add_query_arg( 'post_type', wc_clean( wp_unslash( $_GET['post_type'] ) ), $reset_url ); ?> <div class="woodmart-clear-filters-wrapp"> <a class="woodmart-clear-filters" href="<?php echo esc_url( $reset_url ); ?>"><?php echo esc_html__( 'Clear filters', 'woodmart' ); ?></a> </div> <?php } } add_action( 'woodmart_before_active_filters_widgets', 'woodmart_clear_filters_btn' ); }
To make it work i just added
$min_price = isset($_GET['min_price']) ? wc_clean($_GET['min_price']) : 0; $max_price = isset($_GET['max_price']) ? wc_clean($_GET['max_price']) : 0;
and
if ( 0 < count( $_chosen_attributes ) || 0 < $min_price || 0 < $max_price) {
Thank you.
August 13, 2019 at 11:28 am #137907
Artem TemosKeymasterHello,
We will review this before the next update. Thank you.
Regards
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to create new topics. Login / Register