Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #2934267
Hide product bundle when one or more product are out of stock
Closed

Comments

  •  1
    BRINGEL Sébastien started the conversation

    Hello,

    There is no option to hide a product bundle when one or more products (part of the bundle) are out of stock. How could we make the bundles disapear from our shop when there is some out of stock products ? In fact, we use the plugin for recipes, so if an ingredient is not available, it should hide the bundle ! I ask you : how do you make a tomato sauce without tomatoes ?!? So yeah..

    We us the plugin for this pages : Les recettes du Forum - Le Forum du Local

    Kind regards,

    Sébastien - Le Forum du Local

  •  767
    Janilyn replied

    Hi Bringel,

    Thank you for contacting WPClever Support Forum. 

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions as soon as possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  1
    BRINGEL Sébastien replied

    Hi Janilyn,

    Great ! Thank you for your response :) 

    Kind regards,

    Sébastien B.

  •  1,226
    Dustin replied

    Hi Bringel,

    I did the test and it works correctly with this option https://www.screencast.com/t/GbYrqzeriP on my demo page. Please watch the screen record video https://www.screencast.com/t/bvfnAXkd

    So, please send me your website credentials (wp-admin link, username, password) then I can check it for you. You also can create a dev/staging site with the same configurations then I'll work on it.

    Best regards,
    Dustin

  •   BRINGEL Sébastien replied privately
  •   BRINGEL Sébastien replied privately
  •  1,226
    Dustin replied

    You set this bundle as "Custom quantity" https://www.screencast.com/t/25sOhdJt3ml. That is why when one of the products is out of stock, the bundle is still in stock.

    Please uncheck the "Custom quantity" and it works fine https://www.screencast.com/t/25sOhdJt3ml

    Best regards,
    Dustin

  •  1
    BRINGEL Sébastien replied

    Hi Dustin,


    Thank you again for this answer. Well, but we want our customers to choose the amount for each products either ! Like we said, it is somes recipes so if they are 10 personnes for dinning, they should add some more quantity ! (but not necessary for all products..)

    The best thing would be to have a simple option : "if one ore more products from bundle are unavailable, then, the bundle disapear from shop"

    It would perfectly cover our entire needs and i'm pretty sure a lot of people would use this.

    What do you think ? Could we do something on that ?


    Kind regards,

    Sébastien B.

  •  1,226
    Dustin replied

    Hi,

    I've added a snippet for you here https://www.screencast.com/t/pEsDRyHg6oZ

    Now the bundle that contains one out-of-stock product will be hidden https://www.screencast.com/t/7gWGZzncV88

    Please clear the cache before testing again https://www.leforumdulocal.fr/categorie-produit/les-recettes-du-forum/

    Added snippet for backup:

    add_action( 'wp_footer', 'woosb_footer_css', 99 );
    function woosb_footer_css() {
        ?>
        <style>
            .woosb-out-of-stock {
                display: none !important;
            }
        </style>
        <?php
    }
    add_filter( 'woocommerce_post_class', 'woosb_product_class', 99, 2 );
    function woosb_product_class( $class, $product ) {
        if ( $product->is_type( 'woosb' ) && ( $items = $product->get_items() ) ) {
            $outofstock = false;
            foreach ( $items as $item ) {
                $_product = wc_get_product( $item['id'] );
                if ( ! $_product || ! $_product->is_purchasable() || ! $_product->is_in_stock() || ( ! $_product->has_enough_stock( $item['qty'] ) ) ) {
                    $outofstock = true;
                    break;
                }
            }
            if ( $outofstock ) {
                $class[] = 'woosb-out-of-stock';
            }
        }
        return $class;
    }

    Best regards,
    Dustin

  •  1
    BRINGEL Sébastien replied

    Hi Dustin,

    Oh that's nice ! Thank you :)

    It seems to work, we will do some testing and if we have an issue or something we come back :)

    Have a nice end of year 2021 in the meantime :D

    Kind regards,

    Sébastien B.

  •  1,226
    Dustin replied

    You're welcome!smile.png

    If you are satisfied with our plugin and support, please reward it with a full five-star ★★★★★ rating. https://wordpress.org/support/plugin/woo-product-bundle/reviews?rate=5#new-post
    Thank you in advance! ♥

    Best regards,
    Dustin