• After the 5.6.4 version the bundle stock status changing if one of the bundled product is unpurchasable, BUT it not works if the unpurchasable product is a variable product.

    • This topic was modified 3 years, 6 months ago by MateDan.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author WPClever

    (@wpclever)

    Hi @matedan

    I’ve tested and seen it works fine on my demo page https://www.screencast.com/t/HOrwoxpyHPx

    Could you please send me some screenshots about your configuration on variable products and also bundle?

    Thread Starter MateDan

    (@matedan)

    Please check screenshots: https://www.screencast.com/t/9pM4S6GTPQ

    Plugin Author WPClever

    (@wpclever)

    The bundle stock status here https://www.screencast.com/t/Bdc0wqdv was added by the theme and needs to add custom code to change this status base on the selected variation.

    About stock management at bundle level, please read our article here https://www.ads-software.com/support/topic/how-to-configure-the-stock/

    Hi @wpclever

    In the info popup your plugin says: “By default, the bundle’ stock was calculated automatically from bundled products.
    The stock management works well in case the bundle has only simple products.
    My question is: how do you calculate the stock of a bundle if the bundle has variable product in it?

    Plugin Author WPClever

    (@wpclever)

    @ucsendre

    Yes, that’s right! When having a variable product inside the bundle, we can’t check each variation to get the right stock quantity. It still bases on the buyer selection.

    But don’t worry! If buyers choose a variation which out-of-stock or not enough stock, they can’t buy the bundle.

    If you want to change the text here https://www.screencast.com/t/Bdc0wqdv, as I said above, I need to add custom code to do that. So, please send me this bundle link then I can check it first.

    Hi @wpclever

    Yes, I know the bundle is not purchasable when an out-of-stock variation is selected in it.

    However we would like to keep the appearence of our site to match our expectations in case of every product may it be any kind of product.

    What we are missing is that the “In stock” status mark of the complete bundle should match the selected variations status.

    Please see here: https://www.screencast.com/t/Z93yHWw9

    If this can be fixed by using custom code please let us know but I think that could be added to the plugin code.

    You can test here:
    https://store.bvfheating.com/product/test-product/

    Plugin Author WPClever

    (@wpclever)

    @ucsendre Please add below snippet (How to add custom code?). I’ll check and fix for other themes soon.

    add_action( 'wp_footer', 'woosb_fix_stock_for_bvfheating', 99 );
    function woosb_fix_stock_for_bvfheating() {
    	?>
        <script type="text/javascript">
          jQuery(document).on('found_variation', function(e, t) {
            var $product = jQuery(e['target']).closest('.woosb-product');
    
            if ($product.length) {
              if (!t['is_in_stock'] && t['availability_html'] && t['availability_html'] !== '') {
                $product.closest('.product-summary').find('p.stock').not('.stock-new').addClass('stock-ori').hide();
                jQuery(t['availability_html'].replace('class="', 'class="stock-new ')).
                    insertBefore($product.closest('.product-summary').find('form.cart'));
              } else {
                $product.closest('.product-summary').find('p.stock-new').hide();
                $product.closest('.product-summary').find('p.stock-ori').show();
              }
            }
          });
    
          jQuery(document).on('reset_data', function(e) {
            var $product = jQuery(e['target']).closest('.woosb-product');
    
            if ($product.length) {
              $product.closest('.product-summary').find('p.stock-new').hide();
              $product.closest('.product-summary').find('p.stock-ori').show();
            }
          });
        </script>
    	<?php
    }

    Hi @wpclever

    Thank you for the fix.
    I have made some changes in your script to avoid this: https://www.screencast.com/t/eP0osqs4P6

    add_action( 'wp_footer', 'woosb_fix_stock_for_bvfheating', 99 );
    function woosb_fix_stock_for_bvfheating() { ?>
    <script defer id="woosb_fix_stock_for_bvfheating" type="text/javascript">
    jQuery(document).on('found_variation', function(e, t) {
        var $product = jQuery(e['target']).closest('.woosb-product');
        if ($product.length) {
            if (!t['is_in_stock'] && t['availability_html'] && t['availability_html'] !== '') {
                $product.closest('.product-summary').find('p.stock-new').remove();
                $product.closest('.product-summary').find('p.stock').addClass('stock-ori').hide();
                jQuery(t['availability_html'].replace('class="', 'class="stock-new ')).
                insertBefore($product.closest('.product-summary').find('form.cart'));
            } else {
                $product.closest('.product-summary').find('p.stock-new').remove();
                $product.closest('.product-summary').find('p.stock-ori').show();
            }
        }
    });
    jQuery(document).on('reset_data', function(e) {
        var $product = jQuery(e['target']).closest('.woosb-product');
        if ($product.length) {
            $product.closest('.product-summary').find('p.stock-new').remove();
            $product.closest('.product-summary').find('p.stock-ori').show();
        }
    });
    </script>
    <?php }
    Plugin Author WPClever

    (@wpclever)

    Thanks for the fix!

    Using “.remove()” instead of “.hide()” is better in this case ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Bundle stock status not changing with variable product’ is closed to new replies.