Hello,
this simple plugin really rocks. Worked flawlessly.
I would suggest a small implementation that could help in some cases where attributes names are formed by multiple string.
If people switch one of the words or forget one. Results are zero.
In my case I had an attribute made of people, the name of the terms was people’s Surname and Name.
Anyone searching switching Name and Surname in search would have zero results.
So I’ve edited the plugin, to allow a search for each word just when looking for the attribute I needed:
function wsatt_brands_where( $where = '' ) {
global $wpdb;
$wsatt_attributes = get_option( 'wsatt_attributes' );
if ( isset( $wsatt_attributes ) && is_array( $wsatt_attributes ) && count( $wsatt_attributes ) > 0 ) {
foreach ( $wsatt_attributes as $attribute ) {
$where .= " OR $wpdb->posts.ID IN (SELECT $wpdb->posts.ID
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = 'product'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = '" . esc_sql( $attribute ) . "'
AND $wpdb->terms.name LIKE '%" . get_search_query() . "%')";
// if the attribute is "peoples"
if ( $attribute = 'pa_people' ){
// search for each word in the search query
$words = explode( ' ', get_search_query() );
foreach ( $words as $word ) {
$where .= " OR $wpdb->posts.ID IN (SELECT $wpdb->posts.ID
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = 'product'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = '" . esc_sql( $attribute ) . "'
AND $wpdb->terms.name LIKE '%" . $word . "%')";
}
}
// end the attribute is "peoples"
}
}
return $where;
}
}
I’ve just added the lines between:
// if the attribute is “peoples”
and
// end the attribute is “peoples”
And it does the trick.
Maybe an additional option for each enabled Attribute, to broaden searches on specific attribute terms names would be a nice addition to this nice plugin ??
Thanks.
Hello. I know there was another topic like this one in the support forum, but it was closed without a clear definition.
Would it be possible to search for multiple attributes? I’ve a client which sells medicines, it would be great, for example, to search by manufacturer and specialty.
Thanks in advance!
]]>When using the search I noticed that I couldn’t search for some of my products via their attribute value. When I looked into the differences between the two, I noticed that one was a global attribute and the other was manually entered for that product. It seems that if the product is using a global attribute it works but if it is manual it doesn’t. Please can you fix this issue.
]]>Hi there,
Great plugin! It looks like the plugin is not compatible with HPOS, is there a workaround or update for this?
Thank you!
]]>The plugin works fine, it shows the results, but in the search bar it shows: No results found for “…..”
Can this be fixed?
Imagine I have two Attributes “COLOR & SIZE” and that I have 5 products.
Inside product #1 – I have COLOR = blue & SIZE = small
Inside product #2 – I have COLOR = black & SIZE = big
Inside product #3 – I have COLOR = red & SIZE = small
Inside product #4 – I have COLOR = blue & SIZE = small
Inside product #5 – I have COLOR = red & SIZE = small
If user goes to the search bar and types “small” it shows products #1, #3, #4, and #5
But if user types on the search bar “red small” it shows nothing.
Is there a way the search bar can show results if user types two or more Attributes together while searching?
Like:
“red small”
“blue small shirt”
etc, etc…
]]>Hii Sir,
In there search field size(32b, 30c) was not search exactly work for showing product. Can you help me?
]]>Hi there,
Thank you for your work on the plugin!
Would you consider adding WC product tags in the list of things to search for?
Thank you.
Iain
]]>I have an attribute called SKU but it does not seem to work on all products when using the search bar.
Please fix this.
]]>Hi,
I use WPML and the search results show both languages.
Can you please make it compatible?
Thanks
]]>Hi!
Installed it, and does not work 100%.
I have an attribute “Hersteller”, which is the manufacturer. When I search for it, then about half of the products now show up, but not all.
I have WordPress 5.7, WooCommerce 5.1.
Have nothing in the Stats Log of WooCommerce.
Any idea? Anything I can provide to help fix his?
Thanks