• Hi, I’m using your plugin with WooCommerce. I want to search product variants but not to display them in results – the result items should be products, not variants (the link is not valid and it does not make a sense). Please, is there a way how to

    • remove variants from results
    • OR link them correctly to relevant product

    thank you

Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi!

    While this is the most optimal solution, the only way I can think of is to remove variation after the search post-process with a filter, like so:

    add_filter( 'asl_results', 'asl_remove_variation', 1, 1 );
      
    function asl_remove_variation( $results ) {
      foreach ($results as $k=>$v) {
        if ( $v->post_type == 'product_variation' )
          unset($results[$k]); 
      }   
      return $results;
    }

    Use this code in the functions.php file in your active theme directory.

Viewing 1 replies (of 1 total)
  • The topic ‘How to remove product variant from results’ is closed to new replies.