• Resolved diplomatperfume2018

    (@diplomatperfume2018)


    hi thanks for your nice plugin
    there is an issue in your plugin that if you develop, it would be better.
    the issue is that when user search a product in your search bar, the results show
    “in stock” and “out of stock” products mixed. if the results be sorted from “in stock” first and “out of stock” rest, it is absolutely better.
    thanks

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

    (@mihail-barinov)

    Hello,

    You are right about this. Maybe I add such feature to the next plugin releases.
    But for now you also can add this feature by using following code snippet:

    add_filter( 'aws_search_results_products', 'aws_search_results_products' );
    function aws_search_results_products( $products ) {
        usort($products, function ($item1, $item2) {
            $product1 = wc_get_product( $item1['id'] );
            $product2 = wc_get_product( $item2['id'] );
            if ( 'outofstock' !== $product1->get_stock_status() ) {
                return -1;
            }
            if ( 'outofstock' !== $product2->get_stock_status() ) {
                return 1;
            }
            return 0;
        });
        return $products;
    }

    You need to add it somewhere outside plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
    Also, after adding this code, you need to re-index plugin table.

    Regards

Viewing 1 replies (of 1 total)
  • The topic ‘sorting’ is closed to new replies.