“out of stock visibility” except a list of products

[ad_1]

Hello Friends,

The out of stock visibility option in woocomerce permits to hide all products which reach a certain stock quantity, lets say 1. But suppose having that option applied, still you need to not hide a list of products which reach the quantity 1. I played with the hook pre_option_woocommerce_hide_out_of_stock_items, but I cant get it to work just for a specific product or a list of products, If I activate this snippet then unhides all products and not only the products I want to unhide.

My code bellow, many thanks in advance for any light provided.

Júlio

add_filter( ‘pre_option_woocommerce_hide_out_of_stock_items’, ‘myfunc_hide_out_of_stock_exception’,1,1 );

function myfunc_hide_out_of_stock_exception( $hide )
{
global $product;
if (is_product())
{
if( $product->get_sku() == “0808503010”)
$hide=’no’;
return $hide;
}
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer