Support » Plugin: Ajax Search Lite » Woocommerce onsale product missing from search display

  • marahman.b2b

    (@marahmanb2b)


    Hi,

    Its been noticed woocommerce on sale products not showing up in “Results box viewport (in item numbers)” irrespective of 4 result selection where as the search products are 2 or 3.

    onsale product only showing in result as last item of the search product under “more result…” tab after opening full result windows.

    here is the settings screenshot http://prntscr.com/lj54qc

    We would like to make onsale product show up in “Results box viewport (in item numbers)” kindly guide us how to achieve it… any script of css?

    your earliest support would be highly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    With a custom code it might be possible actually, I am not sure. Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter('asl_results', 'asp_display_sale_products_first', 10, 1);
    add_filter('asp_results', 'asp_display_sale_products_first', 10, 1);
    function asp_display_sale_products_first($results) {
      $first = array();
      $last = array();
      if ( class_exists('WooCommerce') ) {
        foreach ($results as $k => &$r) {
          if ( isset($r->post_type) && ($r->post_type == 'product' || $r->post_type == 'product_variation') ) {
            $p = wc_get_product($r->id);
            if ( $p->is_on_sale() ) {
              $first[] = $r;
            } else {
              $last[] = $r;
            }
          } 
        }
      } else {
        return $results;
      }
      
      return array_merge($first, $last);
    }

    Best regards,
    Ernest M.

    Hi Ernest M

    Thank you for valuable time, i test the given code the result is:

    More result… windows tab brought the on-sale items first in the row, but its not showing up on “Results box viewport”

    how can i make it show on-sale products on “Results box viewport”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce onsale product missing from search display’ is closed to new replies.