Home Forums WoodMart support forum Hide out of stock products or move them at the end

Hide out of stock products or move them at the end

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #547342

    razvanli
    Participant

    Hello

    I am using the Layouts to create this page and I have some products that are Out of Stock, but I do not want to remove them from the website.
    The best option will be to move them at the end of the list.
    Or at least to hide them in the elementor layout.

    How can I do that?

    #547472

    Hello,

    You need to hide out of stock products from the catalog. Navigate to Woocommerce > Settings > Product > Inventory and you will find this option.

    Best Regards

    #547484

    razvanli
    Participant

    This is what I was saying. I dont want to hide them from the entire site.
    Is there any other option?

    #547583

    pr
    Participant

    What I do is change the publication date (I have the category list ordered by last published). Changing the date to previous time thus orders results.
    But it is true that it would be interesting to have an automatic option that takes temporarily out-of-stock products to the final part.

    #547655

    Hello,

    You want to move the “out of stock” products at the end of the archive page? If yes, try to add the following code in the function.php of the child theme.

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

    Best Regards.

    #547732

    razvanli
    Participant

    Thanks a lot for this.

    You know what will be the perfect scenario for me? To have this products at the end of the list, when showing an archive page and to have the option to have them greyed out.
    Any ideas how to achieve that?

    #547883

    Hello,

    This code will work on the archive pages.You cannot gray out from the archive pages. If you want to move the “out of stock” products from the end of the shop page you can use this code.

    Best Regards.

    #547897

    razvanli
    Participant

    I can confirm this code worked

    #547902

    Most Welcome!!!.

    I’m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.

    We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.

    Thanks for contacting us.
    Have a great day.

    Topic Closed.
    Best Regards.

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

The topic ‘Hide out of stock products or move them at the end’ is closed to new replies.