Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3099179
Bundle Product Sorting
Closed

Comments

  • Jawad started the conversation

    Hi,

    I want that bundles show after the main products when user search something on the website. 

    You can say that bundles should appear after the simple/variable products on archive and search pages. 

    How can I do that ? 

  •  767
    Janilyn replied

    Hi Jawad,

    Thank you for contacting WPClever Support Forum. 

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions if that is possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  153
    Henry replied

    Enable Default WooCommerce Product Sorting

    To enable the default WooCommerce product sorting, go to your WooCommerce → Settings → Product Tab.

    In the drop-down menu, you can see the available default product sorting that focuses on different classifications such as price and popularity.

    WooCommerce-Product-Sorting.jpg

    To see this sorting in your WooCommerce dashboard, go to Products → All Products → click on Sorting. The results on the page will filter out the products to reflect your choice.

    WooCommerce-Product-Sort.jpg

    If you want to customize the order of the sorting menu, click on Edit of any bundles product → scroll down to the Product data widget → click on the Advanced tab, where you will find the Menu order for changing the order. In the backend, this action utilizes the woocommerce_catalog_order by a hook.

    1102135853.png


    Best regards,
    Henry N.

  • Jawad replied

    Hi, 

    I am not using default sorting of WooCommerce. 

    Out of stock products are shown at the end of page by using a hook. 

    In this similar way, I want that bundled products always appear after simple/variable products. 

    How can I do this? 

  •  153
    Henry replied

    Please add the below snippet:

    add_action( 'pre_get_posts', 'woosb_sortby_menu_order_query' );
    function woosb_sortby_menu_order_query( $query ) {
        if ( isset( $_REQUEST['s'] ) ) {
            $query->set( 'orderby', 'menu_order' );
            $query->set( 'order', 'ASC' );
        }
    }

    Then you can rearrange all of your products manually by dragging and dropping on the Products > Sorting page. Please watch the screen record video https://www.screencast.com/t/o6fNqT5C

    If you also want to place out-of-stock products at the end, you can use the below snippet:

    add_filter('posts_clauses', 'order_by_stock_status');
    function order_by_stock_status($posts_clauses) {
        global $wpdb;
        // only change query on WooCommerce loops
        if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
            $posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
            $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
            $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
        }
        return $posts_clauses;
    }

    These snippets will work together, and the result https://www.screencast.com/t/8SEJVxLq

    -----

    If it still doesn't work for your site, please send me your website credentials (wp-admin URL, username, password) then I can check and fix it for you. You also can create a dev/staging site with the same configurations then I'll work on it.


    Best regards,
    Henry N.