Home Forums WoodMart support forum FBT Block Visibility Issue – Shows Even When All Products Out of Stock

FBT Block Visibility Issue – Shows Even When All Products Out of Stock

Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #674210

    StravinMarvin
    Participant

    Hello,

    I’m using your theme with Gutenberg and implementing Frequently Bought Together (FBT) bundles. I’ve encountered an issue that’s impacting the functionality of my store.

    Issue: The FBT block displays on product pages even when all products in the bundle are not available for sale (out of stock and backorder not enabled). This creates a poor user experience as customers see empty bundles with only the main product.

    Expected behavior: When none of the products in an FBT bundle are available for sale, the entire block should be hidden automatically.

    Is there a way to implement conditional visibility for the FBT block based on the bundled product’s availability? This feature would significantly improve the shopping experience on my site.

    Thank you for your assistance!

    #674285

    Hello,

    Try to add the following JS code in Theme Settings > JS and check how it works.

    document.addEventListener('DOMContentLoaded', function () {
      const fbtBlock = document.querySelector('.wd-fbt-purchase');
      const fbtDesc = fbtBlock?.querySelector('.wd-fbt-desc');
    
      if (fbtBlock && fbtDesc && fbtDesc.textContent.trim() === 'For 0 items') {
        // Hide FBT purchase section
        fbtBlock.style.display = 'none';
    
        // Hide the full FBT form including product list and title
        const fbtForm = fbtBlock.closest('.wd-fbt-form');
        if (fbtForm) {
          fbtForm.style.display = 'none';
        }
      }
    });

    Best Regards,

    #674309

    StravinMarvin
    Participant

    hello and thank you for your help.
    unfortunately this doesn’t work, nor when i put it in global js or when i put it after document is ready.

    #674321

    StravinMarvin
    Participant

    okay i changed your code a little and this now works –

    document.addEventListener('DOMContentLoaded', function () {
      const fbtBlock = document.querySelector('.wd-single-fbt');
      const fbtDesc = fbtBlock?.querySelector('.wd-fbt-desc');
    
      if (fbtBlock && fbtDesc && fbtDesc.textContent.trim() === 'For 1 item') {
        // Hide FBT purchase section
        fbtBlock.style.display = 'none';
    
        // Hide the full FBT form including product list and title
        const fbtForm = fbtBlock.closest('.wd-fbt-form');
        if (fbtForm) {
          fbtForm.style.display = 'none';
        }
      }
    });

    problem was it wasn’t 0 products but one product, sense the main product is still in stock – only the bundle is not. also i changed the selector to the whole FBT block instead of just the sale list.

    my only question is – how will this affect load times? i feel it would be much more efficient if this was done within the core theme code and not load the block at all if its not relevant, instead of loading it and then setting display to none.

    #674366

    Hello,

    Sorry for the inconvenience, but that was a little issue, we have fixed it and released the patch as well.

    Please remove the code that I shared with you previously and also your code as well that you used, and then apply the theme patch: 674339,. It should resolve your issue.

    Please try and let me know the result.

    Best Regards,

    #674397

    StravinMarvin
    Participant

    i did, and it created a bug that i cant roll back now so lucky the site isnt in production yet.
    now i see the bundled products only on the list, the product box for them dont appear at all. also it dosent count the products in the “for X item/s” anymore and just says “for 1 item” no matter how many products are bundled.
    please test the solution before advising me to make changes that i cannot revert..

    #674398

    StravinMarvin
    Participant

    okay this changed a lot and caused more trouble then good.
    if i add a simple product to the bundle it works as expected.
    if i select a variation of a product (like a specific color) – i dont see the product box but it only shows up on the list.
    if i select a variable product (not the variation itself but the parent) – it writes its out of stock even though it isnt.
    also for some reason the product pages for variable products do not shoe the product price anymore.
    please fix this ASAP as changes you make through the patcher cannot be reverted!

    #674442

    Hello,

    Could you please provide access to your website and also share the link to the specific page where the issue with the variable product is occurring? This will help us investigate and provide an accurate solution.

    Best Regards,

    #674473

    StravinMarvin
    Participant

    i am sharing access to the site, i beg of you – please do not post anything public about it here. no screenshots, urls, or anything of the sort. thank you in advance.

    #674650

    Hello,

    We have checked this and can confirm the issue you mentioned. We tried reverting the changes made in the patch, but the problem persisted, which indicates that it is likely caused by something else.

    To help resolve the issue with the incorrect display of the variable product, could you please add the following code to your child theme and check if it helps?

    add_action('woocommerce_get_children', function ($children, $product, $visible) {
    	if ($visible) {
    		return $product->get_children();
    	}
    	return  $children;
    }, 10, 3);

    Best Regards,

    #674729

    StravinMarvin
    Participant

    the code you gave me helps with the variable products being “out of stock” in the fbt block. however, when i add the variants themselves (which is what i want to do most of the time) – they still dont have a product box in the fbt block, and are not counted in the “for X items” text. they do appear in the list and are added to cart when selected.

    this is very problematic for me, as i will sometimes need to use the variable product and sometimes the variants themselves, depending on the bundle and where its assigned.

    im thinking of reverting to a backup of the site and going back to the css solution of hiding it when empty.this also means i will lose some work from the last few days and is not ideal at all. and i have to say i am disappointed in this.

    #674736

    StravinMarvin
    Participant

    also i forgot to say – but the changes that you made reverting the patch did fix the problem of prices not appearing on the variable product pages.

    #674835

    Hello,

    Thank you for reaching out and for providing the details of the situation.

    We understand how frustrating this must have been for you, and we sincerely regret that you had to encounter this issue. We’re here to help and always happy to support you in resolving any technical matters related to our theme and its compatibility with other plugins.

    After thoroughly reviewing your request, we’d like to clarify how the Frequently Bought Together block works in its default configuration. Before rendering, each product in the bundle is checked for availability using WooCommerce’s standard is_in_stock() function. This function retrieves the stock status directly from the product’s properties, and when third-party plugins are disabled, everything works correctly — out-of-stock products are not displayed in the FBT block.

    However, we’ve noticed that you are using a custom plugin that likely modifies the product stock status using non-standard methods. In such cases, we kindly ask you to review your code logic and, if possible, adjust it to work with WooCommerce’s built-in is_in_stock() function. This will help ensure that the FBT block functions properly and avoids displaying “empty” bundles on product pages.

    We truly appreciate your trust in our product and are always open to your feedback to help make your experience even better.

    Best Regards,

    #674870

    StravinMarvin
    Participant

    This is simply not true. My custom code uses standard WooCommerce functions, and the is_in_stock() function works exactly as it should. In the screenshot you shared, the stock status is correctly set to “instock”, yet the product box still does not appear – the item only shows in the list without a product box. This issue occurred ONLY after applying your patch.
    I explicitly requested multiple times that you NOT share anything publicly from my website, including screenshots or URLs. This is highly unprofessional and a breach of trust. Please remove the image immediately.
    I am reverting my website to a backup from before your “fixes” and will use the JavaScript workaround (which I had to debug and correct myself, as your initial code was incorrect).
    To summarize this experience:

    Initial JS code provided: incorrect
    Patch 674339: broke core functionality
    Patch system: no rollback option
    Support response: blame the customer’s code rather than acknowledge the faulty patch

    I am extremely disappointed with this experience and the level of support provided.

    #674959

    Hello,

    Thank you for your message. First and foremost, we sincerely apologize for any inconvenience that may have resulted from our intervention. We truly regret that your experience has been unsatisfactory, and we fully understand your frustration.

    Regarding the mentioned screenshot — thank you for bringing it to our attention. It has already been promptly removed. We greatly value your trust and take client confidentiality with the utmost responsibility.

    We are always happy to assist our clients and would like to resolve your issue as quickly as possible. In order for us to investigate the matter more thoroughly and provide an effective solution, we kindly ask that you provide the following:

        Access to the WordPress admin panel
        FTP access to your website

    This will allow our technical team to accurately identify the root cause and deliver a stable fix without additional risk to your site.

    We greatly appreciate your time and trust, and we will do everything we can to ensure your experience moving forward is a positive one.

    Best Regards,

    #675438

    StravinMarvin
    Participant

    i have reverted to the backup from before your patch. it all works as expected except for the initial problem – block displays even when the products in the bundle are not available. i will solve this with the js script from the begining of the conversation. not ideal at all, but working.

    #675538

    Hello,

    You are absolutely right — the issue with the block displaying even when bundled products are unavailable does require a proper fix. We’re interested in implementing this improvement directly in the theme to prevent similar situations in the future.

    In order to deliver a stable and reliable solution, temporary access to your WordPress admin panel and FTP would be very helpful. This would allow us to check how the system behaves in your environment and apply the fix without relying on workaround scripts.

    We’d greatly appreciate it if you would consider granting access. In any case, thank you for your feedback — it’s truly valuable for the continued improvement of the product.

    Best Regards,

    #675689

    StravinMarvin
    Participant

    Hello,

    Thank you for looking further into this issue.

    I’ve thoroughly tested and confirmed that this behavior occurs on a fresh Woodmart installation using Gutenberg as the page builder with your demo content. Since this is reproducible on a clean setup, it appears to be independent of any custom code or specific configurations. If possible, I’d prefer to avoid providing site access unless absolutely necessary, as the issue can be replicated on any fresh installation.

    Steps to reproduce:

    – Create a fresh Woodmart installation with demo content
    – Enable “Hide out of stock items from the catalog” in WooCommerce > Settings > Products > Inventory
    – Create an FBT (requently Bought Together) bundle and assign a product to it
    – Change that product’s status to “out of stock”
    – Assign the FBT bundle to a different product
    – View the product page where the FBT bundle is assigned

    Expected behavior: The FBT block should not display when all products are out of stock.

    Actual behavior: An empty FBT block appears on the product page, even though the products within it are out of stock.

    I appreciate your help in resolving this issue. Please let me know if you need any clarification or additional details.

    #675690

    StravinMarvin
    Participant

    Hello,

    I seem to have answered twice by accident. Sorry about that, please disregard the comment above as this one has some more details. Feel free to delete the previous reply to if you want to keep things more tidy for future readers.

    Thank you for looking into this issue.
    I’ve thoroughly tested and confirmed that this behavior occurs on a fresh Woodmart installation using Gutenberg as the page builder with your demo content. Since this is reproducible on a clean setup, it appears to be independent of any custom code or specific configurations. If possible, I’d prefer to avoid providing site access unless absolutely necessary, as the issue can be replicated on any fresh installation.
    Steps to reproduce:

    – Create a fresh Woodmart installation with demo content
    – Enable “Hide out of stock items from the catalog” in WooCommerce > Settings > Products > Inventory
    – Create an FBT (Frequently Bought Together) bundle and assign a product to it
    – Change that product’s status to “out of stock”
    – Assign the FBT bundle to a different product
    View the product page where the FBT bundle is assigned

    Expected behavior: The FBT block should not display when all products are out of stock.
    Actual behavior: An empty FBT block appears on the product page, even though the products within it are out of stock. i now see the product also appear on the list, but not in a product box, and it wont let you add to cart because one of the products are out of stock.

    I appreciate your help in resolving this issue. Please let me know if you need any clarification or additional details.

    Attachments:
    You must be logged in to view attached files.
    #675917

    Hello,

    Thank you for the detailed explanation.

    After carefully reviewing your reproduction steps, we noticed that the “Hide out of stock products” option is not enabled in your FBT bundle settings. This setting is responsible for hiding products that are out of stock. When enabled, in your described scenario, the FBT block will not display if all associated products are out of stock, or only the main product (which cannot be purchased) will remain visible.

    We’d also like to inform you that this issue has already been resolved in patch #674339.

    Please try the following:

    1. Enable the “Hide out of stock products” option in the FBT settings.
    2. Apply patch #674339.
    3. Check if the issue is resolved afterward.

    If the issue still persists after applying these changes, we kindly ask you to create a staging site with a fresh Woodmart installation, reproduce the issue there, and provide us with admin panel access. This will allow us to investigate the issue in more detail and offer an appropriate solution.

    Thank you in advance for your cooperation!

    Best Regards,

Viewing 20 posts - 1 through 20 (of 20 total)