Home › Forums › WoodMart support forum › Temporarily hide out of stock items in product grid
Temporarily hide out of stock items in product grid
- This topic has 5 replies, 2 voices, and was last updated 2 years, 11 months ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 4, 2022 at 8:25 am #350084
welcomeonboardhkParticipantHello! 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?
February 4, 2022 at 10:25 am #350118
Aizaz Imtiaz AwanKeymasterHello,
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
February 7, 2022 at 9:05 am #350856
welcomeonboardhkParticipantI 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.
February 7, 2022 at 11:15 am #350888
Aizaz Imtiaz AwanKeymasterHello,
Please explain what issues you are facing with the Product Grid element to check it myself and help you out accordingly.
Best Regards
February 9, 2022 at 4:24 am #351543
welcomeonboardhkParticipantWith 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;
}February 9, 2022 at 7:30 am #351565
Aizaz Imtiaz AwanKeymasterHello,
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
-
AuthorPosts
- You must be logged in to create new topics. Login / Register