Home › Forums › WoodMart support forum › FILTER DISAPEAR
FILTER DISAPEAR
- This topic has 11 replies, 2 voices, and was last updated 7 years, 1 month ago by
Artem Temos.
-
AuthorPosts
-
January 18, 2018 at 11:26 am #34002
tvojspletParticipantHi, i have some issues with filter. When i insert sku number (4 digits) in search box the filters disapear from sidebar. If i search with words every thing is ok.
January 18, 2018 at 12:03 pm #34006
Artem TemosKeymasterHello,
We are glad to know that you considered using WoodMart for your web-site. I hope you will be happy with it.
Could you please provide us an instruction how to reproduce the issue on your side?
Kind Regards
XtemosJanuary 18, 2018 at 1:32 pm #34020
tvojspletParticipantHi, i have to say it is very very nice theme. If you check on page http://www.wowbaby.si and typ in 191 and press enter the search result appears but filter on left sidebar disapear (img1.jpg). But if you type for example “HLA” and press enter the search results appera and filter is also visible on left sidebar. (img2.jpg)
Attachments:
You must be logged in to view attached files.January 18, 2018 at 1:56 pm #34032
Artem TemosKeymasterPlease, provide us your admin and FTP access so we can login and check this on your side.
Thank you in advance.
January 18, 2018 at 2:04 pm #34035
tvojspletParticipantIn private content is access
January 18, 2018 at 4:19 pm #34089
Artem TemosKeymasterOK, we found some issue in our theme. It may take some time to investigate it. We will back to you tomorrow.
January 19, 2018 at 7:30 am #34168
tvojspletParticipantok, thanks
January 19, 2018 at 8:06 am #34174
Artem TemosKeymasterOK, we as we can see, WooCommerce widgets don’t take into account our SKU database query. To fix this you will need to edit a few files:
1. First one –
wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-price-filter.php
change this code
if ( $search = WC_Query::get_main_search_query_sql() ) { $sql .= ' AND ' . $search; }
to this one
if ( $search = WC_Query::get_main_search_query_sql() ) { $search_ids = array(); // search for variations with a matching sku and return the parent. $sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean( $_GET['s'] ) ) ); //Search for a regular product that matches the sku. $sku_to_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean( $_GET['s'] ) ) ); $search_ids = array_merge( $search_ids, $sku_to_id, $sku_to_parent_id ); $search_ids = array_filter( array_map( 'absint', $search_ids ) ); $sql .= " AND " . $search; if ( sizeof( $search_ids ) > 0 ) { $sql = str_replace( '))', ") OR ({$wpdb->posts}.ID IN (" . implode( ',', $search_ids ) . ")))", $sql ); } }
2. In this file
woodmart/inc/widgets/class-widget-layered-nav.php
replace this
if ( $search = WC_Query::get_main_search_query_sql() ) { $query['where'] .= ' AND ' . $search; }
with this part
if ( $search = WC_Query::get_main_search_query_sql() ) { $search_ids = array(); // search for variations with a matching sku and return the parent. $sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean( $_GET['s'] ) ) ); //Search for a regular product that matches the sku. $sku_to_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean( $_GET['s'] ) ) ); $search_ids = array_merge( $search_ids, $sku_to_id, $sku_to_parent_id ); $search_ids = array_filter( array_map( 'absint', $search_ids ) ); $query['where'] .= ' AND ' . $search; if ( sizeof( $search_ids ) > 0 ) { $query['where'] = str_replace( '))', ") OR ({$wpdb->posts}.ID IN (" . implode( ',', $search_ids ) . ")))", $query['where'] ); } }
Kind Regards
January 19, 2018 at 9:41 am #34192
tvojspletParticipantThanks that work. I have one question. When i update woocommerce will i have to do the same?
January 19, 2018 at 10:02 am #34195
Artem TemosKeymasterYes, you will need to update the WooCommerce file only. We will fix it in our theme filters. We will try to find some better workaround in the future.
January 19, 2018 at 10:03 am #34196
tvojspletParticipantok thanks for info and fast response.
January 19, 2018 at 10:07 am #34200
Artem TemosKeymasterYou are welcome!
-
AuthorPosts
Tagged: filter
- You must be logged in to create new topics. Login / Register