Home Forums WoodMart support forum Hide out of stock products

Hide out of stock products

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

    aleksandreeu
    Participant

    Hi, maybe its not really related to the theme, but maybe you can help…
    Is it possible to hide all “out of sock” products from the categories, up-selling section, cross-selling section and the section You might be interested ont he porduct page. ?

    Could you provide the snippet?

    So far I have snippet to hide from the categories:

    add_action(‘woocommerce_product_query’, ‘custom_woocommerce_product_query’);

    function custom_woocommerce_product_query($q)
    {
    if (!is_admin())
    {
    $oos_query = new WP_Query([‘meta_query’ => [[‘key’ => ‘_stock_status’, ‘value’ => ‘outofstock’, ‘compare’ => ‘=’, ], ], ‘post_type’ => ‘product’, ‘posts_per_page’ => – 1, ‘fields’ => ‘ids’, ]);
    $exclude_ids = $oos_query->posts;

    $q->set(‘post__not_in’, $exclude_ids);
    }
    }

    #517233

    Hello,

    Out of stock items can be hidden from the catalog by ticking this option in WooCommerce > Settings > Products > Inventory:
    https://snipboard.io/Dvl4OC.jpg

    Best Regards.

    #517235

    aleksandreeu
    Participant

    Thanks!

    #517318

    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 4 posts - 1 through 4 (of 4 total)

The topic ‘Hide out of stock products’ is closed to new replies.