• Resolved Theo Gkitsos

    (@theogk)


    Hello, I use Woodmart Theme and the default WooCommerce Layered Navigation Widgets for filtering and everything works fine on archive pages but not on search page. While I search for something and the search page appears then the filters do nothing, while Relevanssi is active (work fine if Relevanssi is deactivated). They don’t filter the products in the loop, they just show the whole list again like no filters are selected. See this video where I replicate the problem.

    I also opened a ticket in WoodMart support, but could you check if there is something wrong from your end or can be fixed in some way, taking into account the theme’s popularity.

    Thank you, I will appreciate any help,
    Theo

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Theo Gkitsos

    (@theogk)

    UPDATE:
    I switched theme to Storefront and used the default WC filters by attribute and the same thing happens again, so it has nothing to do with Woodmart. This is a issue on your end.

    I also found out that if I disable the new attribute lookup table, the filters work again. So the problem appears when Relevanssi is active AND the attribute lookup table is in use.

    See relevant video

    I switched off the table usage for now but I think this should be fixed, as it’s WC core feature.

    Thanks again,
    Theo

    • This reply was modified 2 years, 5 months ago by Theo Gkitsos.
    Plugin Author Mikko Saari

    (@msaari)

    The attribute lookup table was a new feature for me.

    Looks like this is something that can be fixed, but it requires some extra code. When you enable the attribute lookup table, WooCommerce no longer passes the query variables to the search query like it does without it. Looks like the fix is to do that yourself.

    I’ll have to see if there’s some general solution that can be made to cover all cases, but one solution is to create a filter on relevanssi_modify_wp_query that reads the query variables from the $_REQUEST array and converts them into taxonomy queries that Relevanssi understands.

    For example, to handle product attribute “vari”, with the taxonomy pa_vari and query variable filter_vari, you can do this:

    add_filter( 'relevanssi_modify_wp_query', function( $q ) {
    	$filter_vari = $_REQUEST['filter_vari'] ?? false;
    	$tax_query   = $q->get( 'tax_query' );
    	if ( $filter_vari ) {
    		$tax_query[] = array(
    			'taxonomy' => 'pa_vari',
    			'terms'    => explode( ',', sanitize_text_field( $filter_vari ) ),
    			'field'    => 'slug',
    		);
    	}
    	if ( $tax_query ) {
    		$q->set( 'tax_query', $tax_query );
    	}
    	return $q;
    } );

    This will make the filtering work even with the attribute lookup table enabled. I’ll see if I can come up with some generic filtering capabilities to add to the Relevanssi core, but meanwhile, here’s a solution that will work now.

    Plugin Author Mikko Saari

    (@msaari)

    Here’s a generic solution for product filtering. Please try and see if this works for you:

    https://gist.github.com/msaari/10b1b251eb826ebdc97fee478fe8c249

    Thread Starter Theo Gkitsos

    (@theogk)

    Thank you Mikko, it seems to work fine now. I really appreciate your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Incompatibility with Woodmart theme on search page’ is closed to new replies.