Within search results categories are displayed
-
With filter applied, within search results categories are displayed. It was correct before Woocommerce recent update.
Wordpress 4.9.4 | Woocommerce 3.3.1 | AJAX products filter 1.2.4
The page I need help with: [log in to see the link]
-
Yeah, I can see it on my corporative site, with this plugin and another. And the issue is in woocommerce_product_loop_start and woocommerce_product_loop_end.
My solution in the another plugin is easy, I change these new functions for the oldest functions.
And the “new functions” in my plugin (the plugin is updated and don’t have support.) are:
function woocommerce_product_loop_start_v2( $echo = true ) {
ob_start();
$GLOBALS[‘woocommerce_loop’][‘loop’] = 0;
wc_get_template( ‘loop/loop-start.php’ );
if ( $echo ) {
echo ob_get_clean(); // WPCS: XSS ok.
} else {
return ob_get_clean();
}
}function woocommerce_product_loop_end_v2( $echo = true ) {
ob_start();
wc_get_template( ‘loop/loop-end.php’ );
if ( $echo ) {
echo ob_get_clean(); // WPCS: XSS ok.
} else {
return ob_get_clean();
}
}But for this case is better wait for update.
Thank you very much,
Hello,
Please open plugin settings page and find ‘Template ajax load fix’ option. Turn in on and use jQuery.
You are using old way of how filters are working and it has issues.
Regards,
DimaHello Dima,
Thanks a lot for your advice! Plugin is finally works with this fix.
Kind regards,
YuriHello Dima,
I tried using jQuery and the result is KO.
But, when I use PHP the result is OK.
Thank you very much for your support.
Best regards,
NakuableHello Nakuable.
“I tried using jQuery and the result is KO” – in some rare cases PHP fix is working and will work even faster than jQuery BUT for 90+% of the themes only jQuery works good. Big plus is that jQuery fix works good with other plugins while PHP with big percentage will ignore all other plugins that adds something to the output of the products.
In all situations I’d recommend to turn on jQuery and fix issues that it have with your theme as this is for-long-time fixes.
Regards,
DimaHello Dima,
Now I use a child theme of Firmness. But I don’t know how do fix the issues.
In other topic, I see that now in parent category, the filters don’t show products, but before yes. It’s the correct work?
For your reference, you can enter in the url below:
https://anatronic.com/categoria-producto/equipos-moviles-industriales/Thank you very much for your support.
Hello Dima,
I also noticed that filters does not work for parent category. Only for subcategories, which containing products. If I go one level up, filters are displayed, but does not work: after page reloads, I still can see the same list of subcategories, just like before filtering.
Thank you very much for your support.
Kind regards,
YuriNakuable,
Your theme is using ul.products 2 times. It is not common and updating is first one only.
Filters are added to the first query only where your categories are shown and not to the second one. So when you apply the filters second box(with products) are not changing in any way.
Check this out – https://anatronic.com/categoria-producto/equipos-moviles-industriales/?filters=pantalla-tactil%5B442%5D|usb[361]|rj-45[290]|cpu[358]
No categories at the top. They are filtered out while products are not touched.
Output the top part(with categories) in a common way, without using woocommerce and everything will be working ok.
Regards,
DimaYuri,
“I also noticed that filters does not work for parent category. Only for subcategories, which containing products”:
1) filters are shown only when products exist. No products = no filters. If you show category page with sub-categories that don’t have products there will be no filters.
BUT you can turn on option Show all values and they all will be shown all the time.2) “filters does not work for parent category” – can you provide an example please?
Regards,
DimaHello Dima,
Here are my examples:
Parent category (filters does not work) – https://tmark.ru/product-category/izolyatsiya-germetizatziya-zachita/termousadochnaya-trubka/
Subcategory (filters works fine) – https://tmark.ru/product-category/izolyatsiya-germetizatziya-zachita/termousadochnaya-trubka/termousadochnaya-trubka-tonkostostennaya/
I know that filters are shown only when products exist. All products within parent category are related to parent category and to subcategory as well, via checkboxes “Product categories”.
Meanwhile I`ve done some tests:
If I disable checkbox “Use all plugins on ajax load(can slow down products loading)”, than filters are works for parent and subcategories. But, than I see the same problem from my first post here: with filter applied, within search results categories are displayed.
If I enable option “Use all plugins on ajax load(can slow down products loading)” again, than filters does not work for parent category.Kind regards,
YuriDear Dima, I reply you in bold below:
Your theme is using ul.products 2 times. It is not common and updating is first one only.
Yes, I know it. It’s because we need show the most recent productsFilters are added to the first query only where your categories are shown and not to the second one. So when you apply the filters second box(with products) are not changing in any way.
Filters are added to the first box => It’s OK for me. The second box allways show the recent products.Check this out – https://anatronic.com/categoria-producto/equipos-moviles-industriales/?filters=pantalla-tactil%5B442%5D|usb[361]|rj-45[290]|cpu[358]
No categories at the top. They are filtered out while products are not touched.No categories at the top => I can see it when I apply the 3 filter.
Output the top part(with categories) in a common way, without using woocommerce and everything will be working ok.
It isn’t possible because We need use Woocommerce.
Thank you very much.
Best regard
Dear Dima,
Please, can you help us with it?
Thank you very much for your support.
Best regards.
Hello Nakuable,
I see it now. I wasn’t clearly understanding the problem.
In paid version of the plugin we have option “Display products” – Display always products when filters selected. Use this when you have categories and subcategories on shop pages, but you want to display products on filtering.
In free version we don’t have this. We will probably add it to the free version too but right now we are limited in time.
Regards,
Dima- This reply was modified 6 years, 9 months ago by Dmytro Holovnia.
Dear Dima,
My issue is that when you put any filter, in first “ul.products” you can lsee the 3 parents categories (Equipos móviles industriales, Informática industrial and IoT M2M & telecomunicaciones) It’s not correct work because before woocomerce update, in this “ul.products” the parents category not show (for example in this url: https://anatronic.com/categoria-producto/informatica-industrial/?filters=pantalla%5B432%5D )
I could see this issue in another plugin (Woocommerce ShortCodes Products By Categories), this issue is that the plugin use woocommerce_product_loop_start and woocommerce_product_loop_end to show the products, and with the new functions can’t work ok.
Please See the changes:
=== NEW ===
function woocommerce_product_loop_start( $echo = true ) {
ob_start();
wc_set_loop_prop( ‘loop’, 0 );
wc_get_template( ‘loop/loop-start.php’ );
$loop_start = apply_filters( ‘woocommerce_product_loop_start’, ob_get_clean() );
if ( $echo ) {
echo $loop_start; // WPCS: XSS ok.
} else {
return $loop_start;
}
}function woocommerce_product_loop_end( $echo = true ) {
ob_start();
wc_get_template( ‘loop/loop-end.php’ );
$loop_end = apply_filters( ‘woocommerce_product_loop_end’, ob_get_clean() );
if ( $echo ) {
echo $loop_end; // WPCS: XSS ok.
} else {
return $loop_end;
}
}=== OLD ===
function woocommerce_product_loop_start( $echo = true ) {
ob_start();
$GLOBALS[‘woocommerce_loop’][‘loop’] = 0;
wc_get_template( ‘loop/loop-start.php’ );
if ( $echo ) {
echo ob_get_clean(); // WPCS: XSS ok.
} else {
return ob_get_clean();
}
}function woocommerce_product_loop_end( $echo = true ) {
ob_start();
wc_get_template( ‘loop/loop-end.php’ );
if ( $echo ) {
echo ob_get_clean(); // WPCS: XSS ok.
} else {
return ob_get_clean();
}
}===
If you use woocommerce_product_loop_start and woocommerce_product_loop_end, please add a option to use the oldest function and then your plugin work OK to me and the rest of people with same error.
Thank you very much.
Dear Dima, I think about to mod your plugin to add it, if you want I send you the modifications made. So you can add them in future versions.
It’s OK for you?
If it’s ok, please, send me a email address to send the *.php
Thank you very much.
- The topic ‘Within search results categories are displayed’ is closed to new replies.