Home Forums WoodMart support forum Show Out of stock products at the end

Show Out of stock products at the end

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #298795

    sportsahand
    Participant

    please add this option in theme setting 🥰

    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;
    }
    
    #298809

    Hello,

    For now and I am forwarding this to our development department for considering to add it in the theme, but I am not giving you the guarantee for that because please note that a theme cannot satisfy all requirements as it may cause theme heaviness. Sometimes it may require your own customization. So if the development department finds it fit with the theme environment then surely they will look through it.

    Best Regard

    #312586

    zlato
    Participant

    thx sportsahand

    #312712

    Hello,


    @zlato
    We are Glad that you want this option in our theme for future updates.

    I have already forwarded this to the development department.

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Topic Closed.
    Best Regards.

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Show Out of stock products at the end’ is closed to new replies.