• Resolved suporteitpoweron

    (@suporteitpoweron)


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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @suporteitpoweron

    I understand that you’re having trouble with the Out of stock visibility option and trying to customize it to work for a specific list of products.

    It seems that the pre_option_woocommerce_hide_out_of_stock_items filter hook you’re trying to use affects the global setting in WooCommerce, and hence it applies to all products. Therefore, it’s not the best option for what you’re trying to achieve. Instead, you can use a custom function that checks the stock status of each product individually.

    However, it’s a development territory that may be beyond our area of expertise and assistance as per our support policy.

    Still, if you need customization, we do our best to offer advice and direct you to appropriate resources. Based on the feedback we get from our customers, we highly recommend contacting one of the services on our Customization page. On the other hand, I’ll keep this thread open, allowing other members of the community to contribute their expertise.

    Thank you for your understanding.

    Thread Starter suporteitpoweron

    (@suporteitpoweron)

    Dear Darla A.

    Many thanks for your reply! I will try at the product stock level.

    Best Regards!

    Julio

    Sure, please do let us know! Thank you, @suporteitpoweron

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘hide out of stock visibility, except for a list of products’ is closed to new replies.