How to edit the sort order in the search results of the Searched Products widget for Elementor

This topic has 9 replies, 4 voices, and was last updated 5 days, 12 hours ago ago by Tony Rodriguez

  • Avatar: st7878
    st7878
    Participant
    January 22, 2026 at 09:34

    Hello. In the Searched Products widget for Elementor that you developed, there is no product sorting option in the settings. Therefore, out-of-stock products may be displayed among other products. It would be good to generally implement a “Do not show out-of-stock products” button in the settings. But at the moment, I am interested in how to make out-of-stock products appear at the very bottom (last)?

    Files is visible for topic creator and
    support staff only.
    8 Answers
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    January 22, 2026 at 10:59

    Hello, st7878,

    We have noticed that you are currently using an outdated version of the theme (9.4.7). We kindly ask you to update it to the latest version (9.6.5) to ensure optimal performance and compatibility.

    Best regards,
    8Theme Team

    Avatar: st7878
    st7878
    Participant
    January 22, 2026 at 11:03

    The theme version has no relation to the sorting of products in the search results generated by your widget for Elementor. I am working with the latest version on a local server. Once again, my question: how can I make out-of-stock products appear at the very bottom in the search results?

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    January 22, 2026 at 14:52

    Hi,

    The option you are asking about is not available by default, so you may submit a request for its addition on our Taskboard at https://www.8theme.com/taskboard/. If your idea garners sufficient support from other customers, our development team will carefully evaluate the possibility of including it in a future update.

    In the meantime, you can try using the “Hide out of stock items from the catalog” feature, which can be found in your WooCommerce settings (WooCommerce → Settings → Products → Inventory). As a result, any products that are out of stock will be automatically excluded from search results.

    Best regards,
    8Theme Team

    Avatar: st7878
    st7878
    Participant
    January 22, 2026 at 15:35

    It seems strange to me to ask for snow in winter. After all, logically, from a marketing perspective, there’s no point in showing out-of-stock products at the beginning. But I’ll think about your suggestion to contact the development team with a proposal that “the credits should be at the end of the film, not in the middle.” Since you can’t help me, then please tell me which hooks for sorting this widget uses. I’ll write the sorting code for it myself. Thank you.

    Avatar: Ayan Rahman
    Ayan Rahman
    Support staff
    January 22, 2026 at 16:56

    Hi,

    Thank you for your message and for sharing your thoughts and suggestions.

    Regarding your request, the widget uses standard WooCommerce sorting hooks. You can refer to the following hooks for customization:
    woocommerce_get_catalog_ordering_args
    woocommerce_catalog_orderby
    woocommerce_default_catalog_orderby_options
    Additionally, please read these replies – https://www.8theme.com/search/?bbp_search=woocommerce_get_catalog_ordering_args&bbp_forum_id=128990

    Warm Regards,
    The 8Theme Team

    Avatar: st7878
    st7878
    Participant
    January 22, 2026 at 17:40

    Here’s a working solution that solves my problem. Might be useful to someone.

    add_filter( 'woocommerce_products_widget_query_args', 'custom_sort_products_widget_by_stock' );
    
    function custom_sort_products_widget_by_stock( $query_args ) {
    if ( isset( $query_args['s'] ) ) {
    $meta_query = $query_args['meta_query'] ?? array();
    $meta_query[] = array(
    'relation' => 'OR',
    array(
    'key' => '_stock_status',
    'value' => 'instock',
    'compare' => '=',
    ),
    array(
    'key' => '_stock_status',
    'value' => 'outofstock',
    'compare' => '=',
    ),
    );
    $query_args['meta_query'] = $meta_query;
    $query_args['meta_key'] = '_stock_status';
    $query_args['orderby'] = 'meta_value ASC';
    $query_args['order'] = 'ASC';
    }
    return $query_args;
    }
    Avatar: st7878
    st7878
    Participant
    January 22, 2026 at 17:54

    Thanks for the support! My topic “How to edit the sort order in the search results of the Searched Products widget for Elementor” has been successfully resolved.

    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    January 22, 2026 at 17:54

    Dear st7878,

    It’s great having you in our WordPress & WooCommerce community!

    Every insight you share helps us refine XStore and build tools that empower thousands of online store owners worldwide.

    Together, we grow stronger with every release.

    Topic closed.
    The 8Theme Team

  • Viewing 9 results - 1 through 9 (of 9 total)

The issue related to '‘How to edit the sort order in the search results of the Searched Products widget for Elementor’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.