Forums › Forums › Search & Filter Pro › Plugin doesn't work properly when there are no results
Tagged: No results, woocommerce
- This topic has 4 replies, 2 voices, and was last updated 9 years, 9 months ago by Ross.
-
Anonymous(Private) January 19, 2015 at 10:35 am #10452
Good day,
I’ve been using your plugin on a site we’re developing to sell photos: http://flex.gelderlander.nl/regiobeeld/
The plugin seems to work fine when it can find results (though the string saying how many products are displayed isn’t updated).
However, when it can’t find any results, say when you fill in a load of garble for a title, it doesn’t seem to display a notification that nothing was found. It just lists the entire content of our product database.
Is there a WooCommerce template I should be using instead of archive-product.php?
The jQuery selector I’ve used for the results container is ‘ul.products’.
Anonymous(Private) January 19, 2015 at 10:38 am #10453It seems to work quite a bit better when I use the jQuery selector ‘#main’. However, when searching for product tags (I’ve mapped ‘Fotografen’ to tags) or product categories (again, I’ve mapped ‘Edities’ to categories — this is going to be a service for a Dutch local newspaper, we’re intending on selling photos made by our freelance photographers), the entered query doesn’t display. Is there an easy fix for this?
Kind regards,
Wouter SpaakRoss Moderator(Private) January 19, 2015 at 2:50 pm #10490Hey Wouter
Do you have a link I could look at?
In a regular template there would normally be a message when no products/results are found – for example (taken from http://codex.wordpress.org/The_Loop):
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!-- do stuff --> <?php endwhile; else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
So really it sounds like how your template is handling the case when there are no search results.
Thanks
Anonymous(Private) January 19, 2015 at 2:52 pm #10492It turns out I hooked the results to the wrong DOM Element. When I used #main as my jquery selector, it worked perfectly.
I also found an easy way to get all search terms in the header:
` <?
function return_search_terms($page_title) {
if(is_search()) {
$getText = $_GET;
$searchString = ”;
$searchString .= ‘Zoekresultaten: “‘;
foreach($getText as $key => $value) {
$searchString .= $value;
if(end($getText) !== $value) {
$searchString .= ‘, ‘;
}
}
$searchString .= ‘”‘;
return $searchString;
} else {
return $page_title;
}
}add_filter(‘woocommerce_page_title’, ‘return_search_terms’);
?>Ross Moderator(Private) January 19, 2015 at 4:26 pm #10511Thanks for the info and glad you’re up and running 🙂
-
AuthorPosts