Custom search broken after update
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from langhedev on November 1, 2023, 17:13Hi,
I have some custom code which runs when a user perform a text search from the default woocommerce product searchbox, which includes custom fields in the search performed (so for example it allows to search by sku).
The code is the following:
/**
* Join posts and postmeta tables
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
*/
function cf_search_join( $join ) {
global $wpdb;if ( is_search() ) {
$join .=' LEFT JOIN '.$wpdb->postmeta. ' cfmeta ON '. $wpdb->posts . '.ID = cfmeta.post_id ';
// $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
}
return $join;
}
add_filter('posts_join', 'cf_search_join' );/**
* Modify the search query with posts_where
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
*/
function cf_search_where( $where ) {
global $pagenow, $wpdb;if ( is_search() ) {
$where = preg_replace(
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"(".$wpdb->posts.".post_title LIKE $1) OR (cfmeta.meta_value LIKE $1)", $where );
}return $where;
}
add_filter( 'posts_where', 'cf_search_where' );/**
* Prevent duplicates
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
*/
function cf_search_distinct( $where ) {
global $wpdb;if ( is_search() ) {
return "DISTINCT";
}return $where;
}
add_filter( 'posts_distinct', 'cf_search_distinct' );But with the last update in husky the code doesn't work anymore. It works if I disable the husky plugin.
Any advice?
thanks :-)
Hi,
I have some custom code which runs when a user perform a text search from the default woocommerce product searchbox, which includes custom fields in the search performed (so for example it allows to search by sku).
The code is the following:
/**
* Join posts and postmeta tables
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
*/
function cf_search_join( $join ) {
global $wpdb;
if ( is_search() ) {
$join .=' LEFT JOIN '.$wpdb->postmeta. ' cfmeta ON '. $wpdb->posts . '.ID = cfmeta.post_id ';
// $join .=" LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id";
}
return $join;
}
add_filter('posts_join', 'cf_search_join' );
/**
* Modify the search query with posts_where
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
*/
function cf_search_where( $where ) {
global $pagenow, $wpdb;
if ( is_search() ) {
$where = preg_replace(
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"(".$wpdb->posts.".post_title LIKE $1) OR (cfmeta.meta_value LIKE $1)", $where );
}
return $where;
}
add_filter( 'posts_where', 'cf_search_where' );
/**
* Prevent duplicates
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
*/
function cf_search_distinct( $where ) {
global $wpdb;
if ( is_search() ) {
return"DISTINCT";
}
return $where;
}
add_filter( 'posts_distinct', 'cf_search_distinct' );
But with the last update in husky the code doesn't work anymore. It works if I disable the husky plugin.
Any advice?
thanks :-)
Quote from Pablo Borysenco on November 2, 2023, 12:20Hello
Please try to use husky text search - https://products-filter.com/shortcode/woof_text_filter
Hello
Please try to use husky text search - https://products-filter.com/shortcode/woof_text_filter
Quote from langhedev on November 3, 2023, 16:41Thanks! I'll try it out and let you know
Thanks! I'll try it out and let you know
Quote from Pablo Borysenco on November 6, 2023, 12:07hello
Ok! Welcome;)
hello
Ok! Welcome;)
Quote from langhedev on November 8, 2023, 15:59Hi, it seems to be working :-)
Is there a filter / hook which can be used to customize the output of the text input? (I need to add a tooltip with some help text)
Thanks!
Hi, it seems to be working :-)
Is there a filter / hook which can be used to customize the output of the text input? (I need to add a tooltip with some help text)
Thanks!
Quote from Pablo Borysenco on November 9, 2023, 10:27Hello
Unfortunately the plugin does not have such a feature, you should customize the plugin code - \wp-content\plugins\woocommerce-products-filter\ext\by_text\views\shortcodes\woof_text_filter.php
Hello
Unfortunately the plugin does not have such a feature, you should customize the plugin code - \wp-content\plugins\woocommerce-products-filter\ext\by_text\views\shortcodes\woof_text_filter.php
Quote from langhedev on November 21, 2023, 11:07Hi Pablo,
I have tested the solution thoroughly , and I've come across a problem.
This is my shortcode: [woof_text_filter taxonomy_compatibility="1" sku_compatibility="1" custom_fields="1"]
In "meta section" of the plugin options I've added 3 custom fields which I want to filter for (model_brand, _sku and references), all are configured for "text search" and as "string" value.
Unfortunately, only the sku search seems to be working :-/
Any advice?
Thanks!
Hi Pablo,
I have tested the solution thoroughly , and I've come across a problem.
This is my shortcode: [woof_text_filter taxonomy_compatibility="1" sku_compatibility="1" custom_fields="1"]
In"meta section" of the plugin options I've added 3 custom fields which I want to filter for (model_brand, _sku and references), all are configured for"text search" and as"string" value.
Unfortunately, only the sku search seems to be working :-/
Any advice?
Thanks!
Quote from Pablo Borysenco on November 21, 2023, 13:20Hello
Please read this - https://share.pluginus.net/image/i20231121131851.png
try this shortcode - [woof_text_filter taxonomy_compatibility="1" sku_compatibility="1" custom_fields="model_brand,references"]
Hello
Please read this - https://share.pluginus.net/image/i20231121131851.png
try this shortcode - [woof_text_filter taxonomy_compatibility="1" sku_compatibility="1" custom_fields="model_brand,references"]
Quote from langhedev on November 22, 2023, 13:18Thank you :-)
Thank you :-)
Quote from langhedev on November 22, 2023, 13:20Ok it's working, just one more question: if I hit return while searching, I get redirected on the shop page with this URL "?swoof=1&woof_text=bruna&paged=1", but even if the search has results, they are not shown here
Ok it's working, just one more question: if I hit return while searching, I get redirected on the shop page with this URL"?swoof=1&woof_text=bruna&paged=1", but even if the search has results, they are not shown here
Quote from Pablo Borysenco on November 23, 2023, 11:33Hello
Please drop me exact link to the issue
Hello
Please drop me exact link to the issue
Quote from langhedev on November 24, 2023, 12:15Hi Pablo,
I'm currently testing it in my local enviroment. I'll ask the clienti if it's ok to go online like this so that you can check it out
Hi Pablo,
I'm currently testing it in my local enviroment. I'll ask the clienti if it's ok to go online like this so that you can check it out
Quote from Pablo Borysenco on November 24, 2023, 13:09OK! I will wait for your answer
OK! I will wait for your answer