Home › Forums › WoodMart support forum › Problem with Filter by price slider – it doesn’t change on filter by attributes
Problem with Filter by price slider – it doesn’t change on filter by attributes
- This topic has 13 replies, 2 voices, and was last updated 7 months, 2 weeks ago by Artem Temos.
-
AuthorPosts
-
April 25, 2024 at 11:21 am #560558
media-3572ParticipantHello.
I will need some help.
I have a problem with filter by price widget, and filter by price element in wpbakery.
The same problem happens in both.
When i make a filter by some attribute or attributes I expect the price filter to be changed accordingly to the product prices in the filtered page – but this is not happening. It always shows the same values.
When i make a filters to the way where only one product to be shown in the filtered page i expect the whole filter by price widget and filter by price element in wpbakery to disappear, but it doesnt – again it shows the same values
Regards
Attachments:
You must be logged in to view attached files.April 25, 2024 at 11:24 am #560562
Artem TemosKeymasterHello,
Thank you so much for contacting our support center.
To better assist you, could you kindly test the functionality with default WordPress themes such as TwentyTwenty or WooCommerce Storefront? This will help us determine whether the issue stems from our theme or elsewhere.
Regards
April 25, 2024 at 11:28 am #560563
media-3572ParticipantYou did not read in the private section
I tested this behavior with Storefront theme – and the same problem happens there also.
I tried to test this in Twenty Four theme, but there widgets are missing
Please read the private area
Regards
April 25, 2024 at 2:37 pm #560646
Artem TemosKeymasterIf the problem exists with other themes as well, then it is not caused by the WoodMart theme.
Kind Regards
April 25, 2024 at 10:03 pm #560834
media-3572ParticipantIs this what you call support?
I would like you to ask one of your QAs to test the following behavior:
1. Install Clean WordPress 6.5.2 – this is the latest version so far.
2. Install the latest version of your theme, Woodmart 7.5.1 – this is the latest version so far.
3. Install this theme – Mega Electronics – this is the theme that I want.Once everything is installed, open the homepage and append this URL after the domain name:
/product-category/computer-office/monitors/gaming-monitors/?filter_color=black
Thus, the exact URL should look like this:
https://example.com/product-category/computer-office/monitors/gaming-monitors/?filter_color=black
This will apply a filter to show only one product in the page category – Gaming Monitors.
Then check the “Filter By Price” range.
In my opinion, the “Filter By Price” should not be shown at all if there is only one product in the filtered category – what’s the point of showing a price filter when only one product is displayed?
Test this URL on different browsers – just copy the URL and paste it into different browsers.
OR just go here – https://example.com/wp-admin/edit-tags.php?taxonomy=product_cat&post_type=product
Copy the VIEW on the Gaming Monitors Category and click or copy the actual URL – there you will see 2 products on your page, and filter them by Color Black.
I believe the problem I am facing is related to your importing of Prebuilt websites – this somehow broke the price filtering and perhaps something else I do not know.
If you do what I am asking, I will tell you what I have done so far.
I am attaching a picture of the fresh installation of WordPress and your theme from this URL:
https://example.com/product-category/computer-office/monitors/gaming-monitors/?filter_color=black
Regards
Attachments:
You must be logged in to view attached files.April 26, 2024 at 9:27 am #560909
Artem TemosKeymasterCould you please enable default theme on your website so we can see how it works without WoodMart? Price filter is a WooCommerce functionality and our theme doesn’t influence it. But if it works differently with default theme, then we should check it and fix on your website.
April 26, 2024 at 2:45 pm #561064
media-3572ParticipantLet me explain and show my findings after a lot of testing.
Filrsly there is a big problem with Default Filtering in Woocommerce which I found with Storefront theme. And actually the same problem happens with your theme using the default filtering by price, by attribute – I am talking about the default filtering. I am not talking about your filtering, because you also have filtering which came with your theme.
You can see the problem in the attached pictures with the Storefron theme
The problem with the default filtering with prices and attributes in woocommerce is that it doesnt show the correct values if I am in subcategory. It shown the values from the main category – check the pictures below
For example if i am in subcategory Monitors which is main category “Computers & Office” – the filtering shows the values from the products from “Computers & Office”, not from the products from subcategory Monitors
The problem with your filtering is that it shows the correct values from the subcategories, but price filter doesn’t care the attributes which I am selecting
There are 2 types of filtering with your theme – the default one and the filtering which cames from your theme – and there are 2 types of behavior when I combine them
Please check the behavior on my end
I think I was able to explain everything in the attached pictures
Regards
Attachments:
You must be logged in to view attached files.April 26, 2024 at 3:04 pm #561077
media-3572ParticipantActually I do not care about default filtering. I am not going to use it.
The filtering which I want to use is that which is coming with your theme.
And I think that some of these 2 things are the actual problem with your price filtering is that is not changing:
1. I think that the SQL query which price filtering is using is not currect
2. Maybe the AXAJ call which price filtering is using is not correctOr maybe both
As I told you and if you do not believe me ask some of your QAs to test the behavior from comment – #560834
Regards
April 26, 2024 at 4:24 pm #561105
Artem TemosKeymasterAs we mentioned, filtering functionality is not a part of our theme. Our theme’s filters are just wrappers for WooCommerce filters to add more styling options.
If default filters don’t work as expected then you need to contact WooCommerce developers for help.Kind Regards
April 26, 2024 at 5:27 pm #561146
media-3572ParticipantIf filters are just wrappers for WooCommerce filters with styling then why there are 2 types of “Filter by price” and 2 types “Filter by attributes” which are showing different values in the same category? – check the picture problem8.png
These 2 types of “Filter by price” and 2 types “Filter by attributes” in wigets area are doing different things – I mean your wrappers are making some SQL queries, becouse they show different values then the other ones
Please check what your “wrappers” are doing please.
Regards
Attachments:
You must be logged in to view attached files.April 26, 2024 at 5:38 pm #561153
Artem TemosKeymasterYou need to compare our widget with WooCommerce legacy widgets and not with new filter blocks. They work differently. https://gyazo.com/e850e658432c015cbd628f0a7d181870
April 28, 2024 at 6:58 pm #561467
media-3572ParticipantFollowing your suggestion to test and compare the WooCommerce legacy widget for “Price Filtering,” I’ve observed that both your “Price Filtering” widget and the WooCommerce legacy “Price Filtering” widget behave identically.
While they both function in the same manner, it’s not meeting my requirements. What I’m aiming for is that when I filter by certain attributes, the “Price Filtering” should adjust accordingly. For instance, if there are 5 products displayed after filtering, the price range should reflect the minimum and maximum prices of these products.
I managed to find a partial workaround, but it’s still not ideal. I disabled “Use the product attributes lookup table for catalog filtering” in WooCommerce -> Settings -> Products -> Advanced.
I created a layout where I included your add-on for wpbakery filter by price beneath the page name, and on the sidebar, I added your “Price Filtering” widget to compare both on the same page.
Unfortunately, the results are inconsistent. Please refer to the attached image for clarification.
Your “Price Filtering” widget displays the correct values, which is the expected behavior. However, the issue lies in my reluctance to utilize the sidebar for filtering purposes. Instead, I aim to utilize your wpbakery add-ons for filtering by price and attributes.
My question is: Is this functionality of the wpbakery filter by price add-on not integrated into your theme? If not, why does it behave differently?
Best regards.
Attachments:
You must be logged in to view attached files.April 28, 2024 at 9:04 pm #561483
media-3572ParticipantI’m posting this to help others who are experiencing the same problem as me.
I think I was able to fix the problem by replacing the existing code of function woodmart_get_filtered_price_new() in woodmart\inc\woodmart\inc\integrations\woocommerce\functions.php
with this one
if ( ! function_exists( ‘woodmart_get_filtered_price_new’ ) ) {
function woodmart_get_filtered_price_new() {
global $wpdb;$args = WC()->query->get_main_query()->query_vars;
$tax_query = isset( $args[‘tax_query’] ) ? $args[‘tax_query’] : array();
$meta_query = isset( $args[‘meta_query’] ) ? $args[‘meta_query’] : array();if ( ! is_post_type_archive( ‘product’ ) && ! empty( $args[‘taxonomy’] ) && ! empty( $args[‘term’] ) ) {
$tax_query[] = WC()->query->get_main_tax_query();
}foreach ( $meta_query + $tax_query as $key => $query ) {
if ( ! empty( $query[‘price_filter’] ) || ! empty( $query[‘rating_filter’] ) ) {
unset( $meta_query[ $key ] );
}
}$meta_query = new WP_Meta_Query( $meta_query );
$tax_query = new WP_Tax_Query( $tax_query );
$search = WC_Query::get_main_search_query_sql();$meta_query_sql = $meta_query->get_sql( ‘post’, $wpdb->posts, ‘ID’ );
$tax_query_sql = $tax_query->get_sql( $wpdb->posts, ‘ID’ );
$search_query_sql = $search ? ‘ AND ‘ . $search : ”;$sql = ”
SELECT min( min_price ) as min_price, MAX( max_price ) as max_price
FROM {$wpdb->wc_product_meta_lookup}
WHERE product_id IN (
SELECT ID FROM {$wpdb->posts}
” . $tax_query_sql[‘join’] . $meta_query_sql[‘join’] . ”
WHERE {$wpdb->posts}.post_type IN (‘” . implode( “‘,'”, array_map( ‘esc_sql’, apply_filters( ‘woocommerce_price_filter_post_type’, array( ‘product’ ) ) ) ) . “‘)
AND {$wpdb->posts}.post_status = ‘publish’
” . $tax_query_sql[‘where’] . $meta_query_sql[‘where’] . $search_query_sql . ‘
)’;$sql = apply_filters( ‘woocommerce_price_filter_sql’, $sql, $meta_query_sql, $tax_query_sql );
return $wpdb->get_row( $sql ); // WPCS: unprepared SQL ok.
}
}And it worked
I do not know how this will behave when “Use the product attributes lookup table for catalog filtering” is enabled in WooCommerce -> Settings -> Products -> Advanced, but i do not care. When considering that there is an issue with the price filter when “Use the product attributes lookup table for catalog filtering” is enabled, I prefer to leave it as it is for now.
Actually you have a problem right now with the “FILTER button” in the “Price Filter” add-on for wpbakery in 7.5.1 – it doesn’t work – just refreshes the page and it is not making any filtering – in the url does’t appear also. I mean this doesn’t appear – something like this “?min_price=100&max_price=1826”
I will stick with previous version where “FILTER button” and the code which I am providing and I already replaced – also works
Regards
You can close this ticket
April 29, 2024 at 9:58 am #561546
Artem TemosKeymasterWe are glad that you sorted it out. Feel free to contact us if you have any further questions.
-
AuthorPosts
The topic ‘Problem with Filter by price slider – it doesn’t change on filter by attributes’ is closed to new replies.
- You must be logged in to create new topics. Login / Register