Forums › Forums › Search & Filter Pro › Issues with ‘Custom Results’ & pagination (Woocommerce)
- This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by
Trevor.
-
Anonymous(Private) July 7, 2020 at 6:53 pm #251887
Hi guys,
So I’m wanting to implement Search & filter with Woocommerce, but using the ‘custom’ option instead of the usual, ‘Woocommerce -Shop’ method. Reason is I need the URL to change upon filtering for some dynamic content to work.
I have implemented the Search & filter form like so (in my theme’s product archive .php):
<?php do_action("search_filter_query_posts", 65646); if ( fl_woocommerce_version_check( '3.4.0' ) ? woocommerce_product_loop() : have_posts() ) { /** * Hook: woocommerce_before_shop_loop. * * @hooked wc_print_notices - 10 * @hooked woocommerce_result_count - 20 (FL removed) * @hooked woocommerce_catalog_ordering - 30 (FL removed) */ do_action( 'woocommerce_before_shop_loop' ); woocommerce_product_loop_start(); if ( wc_get_loop_prop( 'total' ) ) { while ( have_posts() ) { the_post(); /** * Hook: woocommerce_shop_loop. * * @hooked WC_Structured_Data::generate_product_data() - 10 */ do_action( 'woocommerce_shop_loop' ); wc_get_template_part( 'content', 'product' ); } } woocommerce_product_loop_end(); /** * Hook: woocommerce_after_shop_loop. * * @hooked woocommerce_pagination - 10 */ do_action( 'woocommerce_after_shop_loop' ); } else { /** * Hook: woocommerce_no_products_found. * * @hooked wc_no_products_found - 10 */ do_action( 'woocommerce_no_products_found' ); } ?>
This works successfully, and the dynamic content works exactly as I require. However, using this method the pagination doesn’t work at all. It works when I take ‘do_action(“search_filter_query_posts”, 65646)’ out of the above, but of course I need this to get into the query for the search. The pagination also works correctly when I use the ‘Woocommerce – Shop’ method, but I don’t get the URL rewrite this way.
Am I adding the Search & filter form into the Woocommerce product query the right way? Could you please direct me how to manually integrate my Search & filter form into a Woocommerce product query properly?
If I can’t get this way to work another method would be to rewrite the URL on filter somehow… I’m using the ‘sandf_change_search_url_rewrite()’ function provided elsewhere in the forum to change the URL when I search. Is there a similar way to change the URL when i filter too (without using the ‘Custom’ method)?
Basically I have a dynamic banner showing on the home page which only shows if it’s the front page. going to myhomepage.com/thehomepageslug removes this banner, even though it’s the same actual page. This way the user will be able to stay on the same page and filter, without the banner appearing. I hope this makes sense.
Here’s the site in development: https://kit-kings.com/
Thanks for your assitance,
Anonymous(Private) July 8, 2020 at 10:14 am #251951Hi Trevor,
Thanks for the fast response.
So the pagination doesn’t actually work with Ajax disabled either. If I take the below code out of the code though, it does.
do_action("search_filter_query_posts", 65646);
With the ‘woocommerce – shop’ method the pagination + Ajax does work correctly. This makes me think it’s not an issue with the css selectors and maybe the way it’s implementing the filter into the query?
-
AuthorPosts