Home Forums WoodMart support forum Temporarily hide out of stock items in product grid

Temporarily hide out of stock items in product grid

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #350084

    welcomeonboardhk
    Participant

    Hello! I turned off “hide out of stock items from catalog” because I indeed want to display out of stock items in searches as well as under categories. But in front page or the shop page, I’d like to hide them in product grids. I tried most of the filter snippets I could find in google (both pre_option_woocommerce_hide_out_of_stock_items and woocommerce_product_query_meta_query kinds of filters) and could hide them only in some of the product grids even on same page. I have played around those filters for some hours and have totally no idea how they work or not work. May I have your advice please?

    #350118

    Hello,

    Sorry but only option is in the woocommerce settings and we could not help with code customizations this is out of our theme support scope.

    Best Regards

    #350856

    welcomeonboardhk
    Participant

    I understand hiding out of stock items is part of woo settings. Now I encounter different behaviours of the same Product Grid element of the theme on different pages. I simply want to know why the differences.

    #350888

    Hello,

    Please explain what issues you are facing with the Product Grid element to check it myself and help you out accordingly.

    Best Regards

    #351543

    welcomeonboardhk
    Participant

    With this snippet I am able to hide out of stock products from Product Grid in Shop page and also the page #20607 however it is not successful in the front page. I wonder why the Product Grid behave differently in front page.

    add_filter( ‘pre_option_woocommerce_hide_out_of_stock_items’, ‘hide_out_of_stock_exception_page’ );
    function hide_out_of_stock_exception_page( $hide ) {
    if ( is_shop() ) {
    $hide = ‘yes’;
    }
    if ( is_page( 20607 ) ) {
    $hide = ‘yes’;
    }

    // the conditions below are all actually referring to the “front” page
    if ( is_front_page() ) {
    $hide = ‘yes’;
    }
    if ( is_home() ) {
    $hide = ‘yes’;
    }
    if ( is_page( 1880 ) ) {
    $hide = ‘yes’;
    }
    return $hide;
    }

    #351565

    Hello,

    We don’t provide support with the third party code snippets. You can try enabling the woocommerce option to hide out of stock products from the catalogue then check back.

    Best Regards

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